javaparseint

cannot find symbol: parseInt


I have allready compiled a few tiny programms in java and everything was fine. But my new code has any problem.

class myclass
{
 public static void main (String[] args)
 {
  int x, y;
  String s ="sssss";
  x=args.length;
  s= args[0].substring(1,2);
  System.out.println("Num of args: "+x);
  System.out.println("List of args:");
  y = parseInt(s,5);
  }
}

The compiler says:

 e:\java\4>javac myclass.java 
  myclass.java:11: error: cannot find symbol   
   y = parseInt(s,5);
       ^   symbol:   method parseInt(String,int)   location: class myclass 1 error

 e:\java\4>

The strange thing is that the compiler jumps over the method substring (as there is no problem) but the method parseInt seems to have any problem. y = parseInt(s); OR: y = parseInt("Hello"); --> Also the same compiler message.

Or does the method not exist? docs.oracle-->Integer says it exists :)

It makes my really crazy as i don't know how to search for the error. I have checked the internet allready, i checked the classpath and the path...

So it would be great if any expert could help me. :)


Solution

  • parseInt is a static method in Integer class. you need to call it like this:

      y = Integer.parseInt(s,5);