Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Can't convert string to int

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can't convert string to int

    For some reason javac can't compile Integer.parseInt(). I tried several programs that have parseInt in them and they don't work so I wrote up a simple little program to test whether the problem is parseInt or something else in the programs. Here's the test program I wrote:

    public class Test
    {
    public static void main(String[] args)
    {
    int a = Integer.parseInt(args[0]);
    System.out.println(a);

    }
    }

    Even with the program above, I still got a compiler error saying: "error: cannot find symbol a = Integer.parseInt();" with an arrow point to the . between Interger and parse. I've tried running the program with Double.parseDouble() and it works just fine. Any ideas as to why I'm getting this error?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: Can't convert string to int

    javac can't compile
    The code compiles OK for me.
    Do you have a class named Integer that you were working with?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can't convert string to int

    I figured out what was wrong. You're right. The program was in a directory with a class called Integer and that was causing the problem.

Similar Threads

  1. [SOLVED] convert int to String
    By itispj in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 14th, 2011, 11:34 PM
  2. [SOLVED] convert String to int
    By b109 in forum Java Theory & Questions
    Replies: 3
    Last Post: June 3rd, 2010, 04:05 AM
  3. Conversion of string into integer in Java
    By JavaPF in forum Java Programming Tutorials
    Replies: 17
    Last Post: January 23rd, 2010, 09:33 AM
  4. Conversion of string into integer in Java
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 17
    Last Post: January 23rd, 2010, 09:33 AM
  5. Convert string to int?
    By connex in forum Java Theory & Questions
    Replies: 1
    Last Post: December 9th, 2009, 05:06 AM