A
Ah Ming
Hi!
I write a java code and compile with the following error. What would happen?
Thanks for your help! The coding is shown below the error message.
Ming
reverse.java:24: cannot resolve symbol
symbol : method parseInt (java.lang.StringBuffer)
location: class java.lang.Integer
num=Integer.parseInt(b);
1 import java.io.*;
2 import java.lang.*;
3 public class reverse
4 {
5 public static void main(String args[]) throws IOException
6 {
7 int num;
8 String str;
9 BufferedReader buf;
10 buf=new BufferedReader(new InputStreamReader(System.in));
11 System.out.print("Input an integer:");
12 str=buf.readLine();
13 num=Integer.parseInt(str);
14 System.out.println("The integer is "+reverse(num));
15 }
16 public static int reverse(int input)
17 {
18 int num;
19 String a;
20 a = Integer.toString(input);
21 System.out.println("\nOriginal string: " + a);
22 StringBuffer b = new StringBuffer(a).reverse();
23 System.out.println("Reverse character string: " + b);
24 num=Integer.parseInt(b);
25 return num;
26 }
27 }
I write a java code and compile with the following error. What would happen?
Thanks for your help! The coding is shown below the error message.
Ming
reverse.java:24: cannot resolve symbol
symbol : method parseInt (java.lang.StringBuffer)
location: class java.lang.Integer
num=Integer.parseInt(b);
1 import java.io.*;
2 import java.lang.*;
3 public class reverse
4 {
5 public static void main(String args[]) throws IOException
6 {
7 int num;
8 String str;
9 BufferedReader buf;
10 buf=new BufferedReader(new InputStreamReader(System.in));
11 System.out.print("Input an integer:");
12 str=buf.readLine();
13 num=Integer.parseInt(str);
14 System.out.println("The integer is "+reverse(num));
15 }
16 public static int reverse(int input)
17 {
18 int num;
19 String a;
20 a = Integer.toString(input);
21 System.out.println("\nOriginal string: " + a);
22 StringBuffer b = new StringBuffer(a).reverse();
23 System.out.println("Reverse character string: " + b);
24 num=Integer.parseInt(b);
25 return num;
26 }
27 }