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);
}
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With