Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   cannot resolve symbol? (http://www.velocityreviews.com/forums/t139152-cannot-resolve-symbol.html)

Ah Ming 12-10-2004 11:55 PM

cannot resolve symbol?
 
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 }

Andy Hill 12-11-2004 12:06 AM

Re: cannot resolve symbol?
 
leo@tech-trans.com (Ah Ming) wrote:

>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.


All times are GMT. The time now is 11:56 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.