NetBeans 6.5 - Integer.parseInt(String)

Hello,
I'm beginner with NetBeans 6.5.
I created a simple hello-java application and a simple hello java-web JSF application.
I have no error with hello-java application for these 2 lines:
String name = "12345";
int aInt = Interger.parseInt(name) ;
but I get exception handler from java-web JSF application as below.
Hope you help me to solve this, Thanks !
Exception Handler
Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
Exception Details: java.lang.NumberFormatException
null
Possible Source of Error:
Class Name: java.lang.Integer
File Name: Integer.java
Method Name: parseInt
Line Number: 415
Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
......

they're different, i was trying to convert the string entered in a TextField to a number, and thought that I already hard coded '12345' in the code to see whether the parseInt works therefore i didn't enter anything in the TextField.
thanks raychen !

Similar Messages

  • Something's wrong with my Integer.parseInt...

    hi...I think something's wrong with my code.
    when i don't add the loop for(int s = h; s > 0; s--) { }, it's correct, but when i do, it shows:
    java.lang.NumberFormatException: 27.0
    at java.lang.Integer.parseInt(Integer.java:414)
    at java.lang.Integer.parseInt(Integer.java:454)
    at chiayaochien3.evaluate.find(evaluate.java:55)
    at chiayaochien3.evaluate.operate(evaluate.java:48)
    at chiayaochien3.Main.main(Main.java:10)
    Exception in thread "main"
    (But i am sure the things in Integer.parseInt is String...)
    public class Main
    public static void main(String[] args)
    String[] data = {"3","+","12","*","27","/","1","-","6", "+", "222"};
    String[] operStack = null;
    String[] numStack = null;
    myStack num1 = new myStack();
    myStack num2 = new myStack();
    myStack oper1 = new myStack();
    myStack oper2 = new myStack();
    int calculateNum1 = 0;
    int calculateNum2 = 0;
    String calculate1 = null;
    String calculate2= null;
    String oper = null;
    double resultNum = 0;
    double result = 0;
    int operSize = 0;
    int numSize = 0;
    int h = 0;
    for(int i = 0; i < data.length; i++) {
    String f = data;
    if(f.compareTo("+") == 0)
    oper1.push(f);
    else if(f.compareTo("-") == 0)
    oper1.push(f);
    else if(f.compareTo("*") == 0) {
    oper1.push(f);
    h++;
    else if(f.compareTo("/") == 0){
    oper1.push(f);
    h++;
    else if(f.compareTo("^") == 0){
    oper1.push(f);
    h++;
    else
    num1.push(f);
    }//end of for
    for(int s = h; s > 0; s--){
    while(!oper1.isEmpty()) {
    calculateNum1 = Integer.parseInt((String)num1.pop());
    oper = (String)oper1.pop();
    if(oper.compareTo("*") == 0) {
    calculateNum2 = Integer.parseInt((String)num1.pop());
    resultNum = calculateNum2*calculateNum1;
    num2.push(String.valueOf(resultNum));
    while(oper1.isEmpty() == false && num1.isEmpty() == false) {
    oper2.push((String)oper1.pop());
    num2.push((String)num1.pop());
    }//end of while
    }//end of if
    else if(oper.compareTo("/") == 0) {
    calculateNum2 = Integer.parseInt((String)num1.pop());
    resultNum = calculateNum2/calculateNum1;
    num2.push(String.valueOf(resultNum));
    while(oper1.isEmpty() == false && num1.isEmpty() == false) {
    oper2.push((String)oper1.pop());
    num2.push((String)num1.pop());
    }//end of while
    }//end of else-if
    else if(oper.compareTo("^") == 0) {
    calculateNum2 = Integer.parseInt((String)num1.pop());
    resultNum = Math.pow(calculateNum2, calculateNum1);
    num2.push(String.valueOf(resultNum));
    while(oper1.isEmpty() == false && num1.isEmpty() == false) {
    oper2.push((String)oper1.pop());
    num2.push((String)num1.pop());
    }//end of while
    }//end of else-if
    else {
    num2.push(String.valueOf(calculateNum1));
    oper2.push(oper);
    }//end of else
    }//end of while
    while(!oper2.isEmpty()){
    oper1.push((String)oper2.pop());
    while(!num2.isEmpty()) {
    num1.push((String)num2.pop());
    while(!num1.isEmpty()) {
    System.out.println(num1.pop());
    while(!oper1.isEmpty())
    System.out.println(oper1.pop());
    }//end of main
    }//end of class

    "27.0" is not an integer. (Well, it is numerically, but it's a representation of a double.)

  • Integer.parseInt() method

    Hi to all
    I'm trying to write a piece of a lexical analizer in Java and I need the method the does the contrary of Integer.parseInt() method in order to do the following:
    once i have as input an integer and with the Integer.parseInt() method i know it's value I want to count it's digits. I'm sure there is a method that do the contrary of Integer.parseInt() method that I can't remeber.
    Thanks for your help
    Maddy

    Integer.parseInt() takes in a String and returns an int value, so the contrary would take in an int value and return a String. Is this what you want?
    You can use Integer.toString()
    Also, when you call Integer.parseInt(String s), you should already have the number as a String (the argument).
    Maybe I am not understanding the question right. If not, please explain exactly what you need.

  • String equivalent of Integer.parseInt()

    Hey..
    Integer.parseInt() reads an integer that is being inputted right? what im looking though is some sort of a String equivalent of Integer.parseInt.
    ex:
    nString = JOptionPane.showInputDialog("Enter number:");
    n = Integer.parseInt(nString);
    what im looking:
    nString = JOptionPane.showInputDialog("Enter text:");
    n = ? (nString);
    a keyword that reads the text inputted.

    how do i reset the counter to 0 if the user tries again? because it doesn't reset and it makes a logical error if the user tries again.
    while (trya != 0){
           if ((trya > 1) || (trya < 0))
              break; 
         else{
      z=JOptionPane.showInputDialog("Choose Difficulty:\n[1]BATHROOM SINGER\n[2]MAINSTREAM MUSICIAN\n[3]GRAMMY WINNER");
      x=Integer.parseInt(z);
      switch(x){
           case 1:
                JOptionPane.showMessageDialog(null,"DIFFICULTY: BATHROOM SINGER");
                String stringInput = JOptionPane.showInputDialog(q1);
            if (stringInput.equals(a1)){
            JOptionPane.showMessageDialog(null, "Correct!");
            i++;
            } else {
                j++;
            JOptionPane.showMessageDialog(null,"Wrong");
    String stringInput29 = JOptionPane.showInputDialog(q15);
            if (stringInput29.equals(a15)){
            JOptionPane.showMessageDialog(null, "Correct!");
            i++;
            } else {
                j++;
            JOptionPane.showMessageDialog(null,"Wrong");
                JOptionPane.showMessageDialog(null,"Correct answers: "+i+"\nWrong answers: "+j+"\nTHANKS FOR PLAYING");
                break;
         default:
              JOptionPane.showMessageDialog(null,"Press either [1] [2] or [3]", "ERROR",JOptionPane.WARNING_MESSAGE);
              break;
        stry = JOptionPane.showInputDialog("Do you want to PLAY AGAIN? \n Press [1] for YES \n Press [0] for NO");
         trya = Integer.parseInt(stry);
      }

  • I have jave 7 I'm trying underscore option in String.   as String strNum = "1000_000";System.out.println("..abc..."  Integer.parseInt(strNum)); but getting error. could you please help in this?

    Hi,
    There is a new feature added in java 7 on integer, called as underscore '_" and it is working fine
    if it is a normal int variable  but if it is coming with String jvm throw the error.
    if  any one of you have java8 installed on your PC can you check this is working on that version.
    int a = 1000_000;   
    String strNum = "1000_000";
    // System.out.println("..abc..."+ Integer.parseInt(strNum));
    System.out.println("a..."+a);
    Thank you,
    Shailesh.

    what is your actual question here?
    bye
    TPD

  • Integer.parseInt() error

    I am writing an applet that reads a file containing groups of 5 lines of which the first 4 hold a number. Then these values are used to draw circles. When I compile, I get this error message: "incompatible types
    found: int, required: java.lang.Integer, ia = Integer.parseInt(a)".
    Suggestions?
    Thanks!
    import java.awt.*;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.geom.*;
    public class Section2 extends Applet {
    TextField tekst;
    public void init() {
    resize(400,400);
    tekst = new TextField(20);
    add(tekst);
    public void paint(Graphics g) {
    try {
    String a, b, c, d, e;
    Integer ia, ib, ic, id;
    File inputFile = new File(tekst.getText());
    FileReader in = new FileReader(inputFile);
    BufferedReader BR = new BufferedReader(in);
    while (e != null){
    a = BR.readLine();
    b = BR.readLine();
    c = BR.readLine();
    d = BR.readLine();
    e = BR.readLine();
    ia = Integer.parseInt(a);
    ib = Integer.parseInt(b);
    ic = Integer.parseInt(c);
    id = Integer.parseInt(d);
    Graphics2D g2d = (Graphics2D)g;
    Ellipse2D.Double circle = new Ellipse2D.Double(ia, ib, ic, id);     
    g2d.setPaint(Color.blue);
    g2d.draw(circle);
    in.close();
    catch (IOException e) {}

    Ok everything works! I still have some questions:
    *** Can anyone tell me why I get this:
    --------------------Configuration: Section2 - j2sdk1.4.0_01 <Default>--------------------
    Note: C:\Program Files\Xinox Software\JCreator LE\MyProjects\Section textfield\Section2.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    Process completed.
    *** Is there a way to go from string to double in one step?
    This is the code:
    import java.awt.*;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.geom.*;
    public class Section2 extends Applet {
         TextField tekst;
         Button knop;     
         public void init() {
              resize(400,400);
              tekst = new TextField(20);
              add(tekst);
              knop = new Button("teken");
              add(knop);
         public boolean action (Event e, Object o){
              if(e.target.equals(knop)){
                   repaint();
              return true;
         public void paint(Graphics g) {
              try {
                   String a, b, c, d, e;
                   Integer ia, ib, ic, id;
                   File inputFile = new File(tekst.getText());
                   FileReader in = new FileReader(inputFile);
                   BufferedReader BR = new BufferedReader(in);
                   e = "start";
                   if (tekst.getText() != null){
                        while (e != null){
                             a = BR.readLine();
                        b = BR.readLine();
                             c = BR.readLine();
                             d = BR.readLine();
                             e = BR.readLine();
                             ia = Integer.valueOf(a);
                             ib = Integer.valueOf(b);
                             ic = Integer.valueOf(c);
                             id = Integer.valueOf(d);
                             Graphics2D g2d = (Graphics2D)g;
                             Ellipse2D.Double circle = new Ellipse2D.Double(ia.doubleValue(), ib.doubleValue(), ic.doubleValue(), id.doubleValue());     
                             g2d.setPaint(Color.blue);
                             g2d.draw(circle);
                        in.close();
              catch (IOException e) {}

  • Integer.parseInt, NumberFormatException

    Hi,
    I'm trying to convert numbers back and forth with parseInt and toHexString.
    The number that I want to manipulate is 56789abc.
    String str = Integer.toHexString(1450744508);
    int i = 0;
    try
    i = Integer.parseInt(str, 16);
    catch(NumberFormatException e)
    e.printStackInfo();
    I'm not sure why I'm getting NumberFormatException, since I think
    56789ABC doesn't cross the line. It's not out of boundary.
    Any suggestion or help really be appreciated.
    Thanks in advance,

    I don't know what you're talking about.
    Integer.parseInt("56789ABC", 16);gives 1450744508
    Works fine.

  • Integer.parseInt problems

    Hi everyone,
    I want to use the Integer.parseInt and Byte.parseByte methods to parse hex strings - the problem is that they don't parse negative 2's complement numbers, they explicitly need a minus sign in front of an otherwise unsigned number to show that it's negative.
    Examples:
    //System.out.println(Integer.parseInt(Integer.toHexString(-1), 16)); //NumberFormatException
    System.out.println(0xffffffff); // but this prints -1
    //System.out.println(Byte.parseByte("ff", 16)); //NumberFormatException
    System.out.println(Byte.parseByte("-1", 16)); // but this worksIs there some other method that will do what I need?
    Regards,
    Jonathan

    Here's a dirty solution:public class Test {
        private static char[] digits = new char[] {
            '0', '1', '2', '3',
            '4', '5', '6', '7',
            '8', '9', 'a', 'b',
            'c', 'd', 'e', 'f'
        public static void main (String[] parameters) {
            String number = Integer.toHexString (parameters[0].equals ("+") ? Integer.MAX_VALUE : parameters[0].equals ("-") ? Integer.MIN_VALUE : Integer.parseInt (parameters[0]));
            if ((number.length () == 8) && (getPosition (number.charAt (0)) >= 8)) {
                String newNumber = "";
                for (int i = 0; i < number.length (); i ++) {
                    newNumber += digits[15 - getPosition (number.charAt (i))];
                number = "";
                boolean carry = true;
                for (int i = 7; i >= 0; i --) {
                    int position = getPosition (newNumber.charAt (i));
                    if (carry) {
                        position = (position + 1) % 16;
                        carry = (position == 0);
                    number = digits[position] + number;
                number = "-" + number;
            int numberAsInt;
            try {
                numberAsInt = Integer.parseInt (number, 16);
            } catch (NumberFormatException exception) {
                // -8000000
                numberAsInt = Integer.MIN_VALUE;
            System.out.println (numberAsInt);
        private static int getPosition (char digit) {
            int position = 0;
            while ((position < digits.length) && (digits[position] != digit)) {
                position ++;
            return position;
    }Start with java Test <yourNumber>: + for Integer.MAX_VALUE, - for Integer.MIN_VALUE.
    I don't claim it's good or efficient: it's working though. There's lots of things to improve.
    Kind regards,
      Levi

  • Finding an integer in string

    let say i have string like string s = "Page (34).jpg"
    now i want to take the 34 as integer..
    i do loop form char 1 to s.length(), i get the string substring
    substring will always return string, but how to know whether the substring is string or integer
    is there any method in java, like isInteger and return boolean?
    Thanks

    Matcher matcher = Pattern.compile("\\d+").matcher(s);
    if (matcher.find())
        int value = Integer.parseInt(matcher.group());
    }

  • How convert integer into string

    Hi,
    I need to convert answer3 from double into String
    answer3 = Double.parseDouble(dij3)/(1 + Math.pow(( Double.parseDouble(tesside_luas_i) / Double.parseDouble(tesside_luas_j) ),0.5847));

    Now the integer value is string but why i cannot get valur from my servlet to my web page
    package net.mybizaid.isodms.servlet;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import net.mybizaid.isodms.*;
    public class SPLDataInputServlet extends HttpServlet {
         public void doPost (HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException
    System.out.println( "******************** Calculation Servlet ******************" );
                   String dij     ;
                   String population_i ;
                   String population_j ;
                   String project_name = "";
                   String project_status = "";
                   double answer;
                   String handler = "";
                   String url                    = "";
                   double answer3;
                   String dij3 ="";
                   String tesside_luas_i ="";
                   String tesside_luas_j ="";
                   double answer2;
                   String dij2 ="";
                   String luas_i ="";
                   String luas_j ="";
                   String counter                    = "";
                   String i                                   = "";
                   handler                          = request.getParameter( "handler" );
                   dij                    = request.getParameter("dij");
                   population_i               = request.getParameter("population_i");
                   population_j               =     request.getParameter( "population_j");
                   project_name               =     request.getParameter( "project_name");
                   project_status               =     request.getParameter( "project_status");
                   dij2                    = request.getParameter("dij2");
                   luas_i               = request.getParameter("luas_i");
                   luas_j               =     request.getParameter( "luas_j");
                   dij3                    = request.getParameter("dij3");
                   tesside_luas_i               = request.getParameter("tesside_luas_i");
                   tesside_luas_j               =     request.getParameter( "tesside_luas_j");
                   HttpSession session = null;
                   session = request.getSession(true);
                   int cnt = counter != null && !counter.equals("") ? Integer.parseInt(counter) : 0;
                   int ii = i != null && !i.equals("") ? Integer.parseInt(i) : 0;
    //Tesside
    if (handler != null && !handler.equals( "" ) && handler.equals( "cal3" ))
                   try
    System.out.println("The DIJ3 value is :"+dij3);
    System.out.println("The tesside_luas_i value is :"+tesside_luas_i);
    System.out.println("The tesside_luas_j value is :"+tesside_luas_j);
                        answer3 = Double.parseDouble(dij3)/(1 + Math.pow(( Double.parseDouble(tesside_luas_i) / Double.parseDouble(tesside_luas_j) ),0.5847));
                        String str = String.valueOf( answer3 );
    System.out.println("The answer value is :"+str);
                         url = "/jsp/model/tessideAnswer.jsp";
                         dispatchErrorMsg( request, response, url, "" );
              catch (Exception e)
                        request.setAttribute("pd.errorMessage", e.getMessage());
                        dispatchErrorMsg( request, response, "/jsp/Error.jsp", e.getMessage() );
    //PotensiPasaran
    if (handler != null && !handler.equals( "" ) && handler.equals( "cal2" ))
                   try
    System.out.println("The DIJ2 value is :"+dij2);
    System.out.println("The luas_i value is :"+luas_i);
    System.out.println("The luas_j value is :"+luas_j);
                        answer2 = Double.parseDouble(dij2)/(1 + Math.sqrt(( Double.parseDouble(luas_i) / Double.parseDouble(luas_j) )));
    System.out.println("The answer value is :"+answer2);
                         url = "/jsp/model/potensiPasaranAnswer.jsp";
                         dispatchErrorMsg( request, response, url, "" );
              catch (Exception e)
                        request.setAttribute("pd.errorMessage", e.getMessage());
                        dispatchErrorMsg( request, response, "/jsp/Error.jsp", e.getMessage() );
    //Reilly
         if (handler != null && !handler.equals( "" ) && handler.equals( "add" ))
                   try
                        System.out.println("The DIJ value is :"+dij);
                        System.out.println("The population_i value is :"+population_i);
                        System.out.println("The population_j value is :"+population_j);
                        answer = Double.parseDouble(dij)/(1 + Math.sqrt(( Double.parseDouble(population_i) / Double.parseDouble(population_j) )));
    System.out.println("The answer value is :"+answer);
                         url = "/jsp/model/reillyAnswer.jsp";
                         dispatchErrorMsg( request, response, url, "" );
              catch (Exception e)
                        request.setAttribute("pd.errorMessage", e.getMessage());
                        dispatchErrorMsg( request, response, "/jsp/Error.jsp", e.getMessage() );
         public void doGet (HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException
              doPost(request, response);
         }//end doGet
         public void dispatchErrorMsg(HttpServletRequest req, HttpServletResponse res,
                                                           String target, String message)
              try
                   RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(target);
                   req.setAttribute("eshop.ErrMessage",message);
                   dispatcher.forward(req, res);
              catch (Exception e)
                   System.err.println( e.getMessage() );
    }//end class

  • Integer.parseInt()

    Hi!
    I have a problem that for an experienced programmer like you should be easy.
    I have in my program:
    int num = Integer.parseInt(numbers);
    And I get:
    Exception in thread "main" java.lang.NumberFormatException: For input string: "195400011111111111111113"
    It (195400011111111111111113) looks like not an integer,and I tried:
    long num = Integer.parseInt(numbers);
    But I get the same error.
    What could I do?
    Thank you,
    Nata

    That number is too big for an int, so Integer.parseInt doesn't like it. It doesn't matter if you put a long on the left side of the equals sign, Integer.parseInt only handles ints.
    Do you know about the Long class? Have you looked at its docs to see if it might have something that can help you?

  • Why Integer.valueOf(String) does not recognize plus sign

    The Integer.valueOf(String) works fine with strings like "-1", but does not work with "+1". The following code throws NumberFormatException:
    int i = Integer.valueOf( "+1" );
    Does anybody know what's the reason for this?
    Thanks,
    -- LK

    Welcome to the forum!
    >
    The Integer.valueOf(String) works fine with strings like "-1", but does not work with "+1". The following code throws NumberFormatException:
    int i = Integer.valueOf( "+1" );
    Does anybody know what's the reason for this?
    >
    The short answer is because it is defined that way.
    The place to start for questions like this is the Javadoc.
    You don't state what Java version you are using but for 1.6 the 'valueOf' method says this
    http://127.0.0.1:8082/resource/jar%3Afile%3A/C%3A/Software/Java/jdk1.6.0_02/jdk-6-doc.zip%21/docs/api/java/lang/Integer.html#valueOf(java.lang.String)
    >
    valueOf
    public static Integer valueOf(String s)
    throws NumberFormatExceptionReturns an Integer object holding the value of the specified String. The argument is interpreted as representing a signed decimal integer, exactly as if the argument were given to the parseInt(java.lang.String) method. The result is an Integer object that represents the integer value specified by the string.
    >
    As you can see the description further refers you to the 'parseInt' method where you will find the answer.
    >
    parseInt
    public static int parseInt(String s)
    throws NumberFormatExceptionParses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang.String, int) method.
    >
    You may have to do a little digging but when you have a question like this you should read the relevant Javadoc sections, search the forum for similar questions, search on the net and then if you still can't figure it out post a thread.

  • Integer.parseInt(in.readLine()) - "null"

    I just realized that if I don't enter a value in the following:
            System.out.print("Enter the column you'd like to mark in: ");
            int col = Integer.parseInt(in.readLine());I get this error:
    Enter the column you'd like to mark in:
    java.lang.NumberFormatException: For input string: ""
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         at java.lang.Integer.parseInt(Integer.java:447)
         at java.lang.Integer.parseInt(Integer.java:476)
         at la5.TicTacToeDriver.main(TicTacToeDriver.java:37)
    Exception in thread "main" Is there a way to prevent this error and prompt the user for a proper input (any integer will work).

    Enclose the parse attempt in a try/catch block.

  • How to convert from integer to string

    import javax.swing.*;
    import java.awt.*;
    public class Hw extends JFrame{
         JButton[] buttons = new JButton[26];
         public Hw(){
              getContentPane().setLayout(new GridLayout(2,13));
              JButton []buttons=new JButton[26];
              for(int i=65; i<90;i++)
                   buttons=new JButton(i+" ");
                   getContentPane().add(buttons[i]);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              pack();
         public static void main(String[] args) {
              Hw win = new Hw();
              win.setVisible(true);
              win.setLocation(50, 100);
    I have 26 buttons and each buttons will contain a character like A,B,C,D,...
    but i dont know how to convert it from integer to string                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    import javax.swing.*;
    import java.awt.*;
    public class Hw extends JFrame{
         JButton[] buttons = new JButton[26];
         public Hw(){
              getContentPane().setLayout(new GridLayout(2,13));
              JButton []buttons=new JButton[26];
              for(int i=0; i<buttons.length;i++)
                   buttons=new JButton(""+('A'+i));
                   getContentPane().add(buttons[i]);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              pack();
         public static void main(String[] args) {
              Hw win = new Hw();
              win.setVisible(true);
              win.setTitle("Hangman Game");
    tjacobs01  , thnx for urgent reply, but i didnt apply your algorithm inside of the my program, if its possible can u compile the program with your codes..
    its a little complex for me i didnt understand anythind :S                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • ParseInt( string ) returns error....

    import java.lang.*;
    String myString = "231";
    int myInt = parseInt( myString );
    returns error....
    I was hoping it would return a decimal integer.
    what am I doing wrong... I am using jdk1.5.*

    I thought that I didn't have to write the
    e ClassName.function().... if I imported the
    Class...Easy mistake to make when it's all new.
    Importing is a way of saying "I want to use this class". But, if you want to use the methods and/or properties of that class, you need to reference it. You need to tell the compiler which class/object your "parseInt" method is drawn from.

Maybe you are looking for