cannot resolve symbol?

Discussion in 'Java' started by Ah Ming, Dec 10, 2004.

  1. Ah Ming

    Ah Ming Guest

    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 }
    Ah Ming, Dec 10, 2004
    #1
    1. Advertising

  2. Ah Ming

    Andy Hill Guest

    (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.
    Andy Hill, Dec 11, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. @lex-kid
    Replies:
    2
    Views:
    2,379
    @lex-kid
    Jul 7, 2003
  2. sufia
    Replies:
    1
    Views:
    3,025
    @lex-kid
    Jul 6, 2003
  3. Jo

    Cannot resolve symbol

    Jo, Apr 9, 2004, in forum: Java
    Replies:
    3
    Views:
    2,690
    Roedy Green
    Apr 10, 2004
  4. vivienne wykes
    Replies:
    4
    Views:
    905
    Roedy Green
    Jul 28, 2004
  5. Replies:
    1
    Views:
    10,112
Loading...

Share This Page