cannot resolve symbol?

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 }
 
A

Andy Hill

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);
Seems clear enough. There is no Integer.parseInt() that takes a StringBuffer
argument. Construct a String using the StringBuffer first, and pass the String
to parseInt.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top