Reputation: 71
I am trying to this code in which test out a simple method. In which you use a method which receives argument. The problem that is happening is with Integer
parse int method.
The command prompt gives an error which is.
java:24:error:cannot find symbol
cholo=Integer.parseInt("123");
^
symbol: method parseInt(String)
location: class Integer
1 error
I am not sure what is causing this.
//Passing arguments in java
//this program demonstrates a method with a paramter
public class PassArg {
public static void main(String[] args) {
int x = 10;
int k;
int cholo;
System.out.println(" I am passing values to displayValue ");
displayValue(5);
displayValue(x);
displayValue(x * 4);
k = 14;
displayValue(14);
cholo = Integer.parseInt("123");
displayValue(cholo);
System.out.println("now I am back in the main");
}
public static void displayValue(int num) {
System.out.println("the value is " + num);
}
}
Upvotes: 3
Views: 6707
Reputation: 36
It has to be something with your JDK build path, try to verify the path to your JDK by right clicking your project->properties->build path and make sure it's pointing to your JDK path. Also, try cleaning your project.
Upvotes: 0
Reputation: 359
You probably have a class "Integer" in your src folder that is overiding the default Integer Java Class. Look at your import statements.
Upvotes: 4
Reputation: 201439
The only explanation I can think of is you have your own Integer
class which you are getting (and not java.lang.Integer
). Rename your other Integer
class, or use the full qualified class name like
int cholo = java.lang.Integer.parseInt("123");
System.out.println(cholo);
Output is
123
Upvotes: 6