How to convert string to integer?
        Posted  
        
            by 
                user1260584
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1260584
        
        
        
        Published on 2012-03-28T04:08:26Z
        Indexed on 
            2012/03/28
            5:30 UTC
        
        
        Read the original article
        Hit count: 195
        
So I'm having a hard time with my situation and need some advice. I'm trying to convert my two Strings that I have into integers, so that I can use them in math equations. Here is what I tried, however it brings me an error in the app.
'     equals.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
                            num1 = edit.getText().toString();
            num2 = edit.getText().toString();
            int first = Integer.parseInt(num1);
            int second = Integer.parseInt(num2);
            edit.setText(first + second);
        }
    });
Is there something that I am doing wrong? Thank you for any help.
EDIT: Yes this is Java. num1 and num2 are strings that I have previously named. What do you mean by trim?
© Stack Overflow or respective owner