Im making a program and I've to take a user input in character array. But it's giving an error which shows no suggestions available. Please help me out of it. Im posting my class code too.
P.S: Infix Array is a char.

import java.util.*;
import java.util.Scanner;
public class Conversion 
  public static void main(String [] args)
      stack stk = new stack();
      int top = -1; boolean IsOperator;
      System.out.print("Enter the infix notation that you want to convert: ");
      Scanner scanner = new Scanner(System.in);
      stk.infix[20] = scanner.next().toCharArray(); //here it is giving the error
      int a = 0;
      while(a < stk.infix[a])
        IsOperator = stk.CheckOperator(stk.infix[a]);
4 Years
Discussion Span
Last Post by stultuske

Im not calling any stack library. I made a class named as stack. "Type mismatch: cannot convert from String to char" this is the error.


ahmed: I didn't ask for a library, I asked what code you are using. I know stack is a class, and one you've written yourself, since you didn't follow naming conventions.

well ... there you have it.
char b = "H";
is invalid, since "H" is a String.

I have no idea on which line of your code this (or something simiilar) occurs,you'll have to be more specific.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.