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.toString();
      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]);
      }
  }
}

Recommended Answers

All 3 Replies

what stack class are you using? what error is it giving?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.