• Register
0 votes
16 views

I am new to java programming . I was practicing some code about string. I wrote a code:

public class NewClass {
    
    
    public static void main(String[] args) {
        int  m ;
        String s ;
        
        
        m = Integer.parseInt(ss);
        
        System.out.println(ss);
        
        
    }
    
}

But that gives me some error:

Exception in thread "main" java.lang.NumberFormatException: null
	at java.lang.Integer.parseInt(Integer.java:542)
	at java.lang.Integer.parseInt(Integer.java:615)
	at javastackoverflow.NewClass.main(NewClass.java:13)
C:\Users\Hp\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)

What is the problem in my code and why am I getting this error?

Can anyone help me out?

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

0 votes
Integer.parseInt(String s) is the most common way of converting numbers represented by String variables to int (primitive) in Java. The example below shows how to use the parseInt(...) method to convert a Str
public static void main(String[] args) {
        String s = "25";
        int m = Integer.parseInt(s);
        System.out.println(m);
}

 

11 6 4
34,950 points

Related questions

0 votes
1 answer 16 views
16 views
Problem: I have done: cut -f FR07937945--FR07937944_gridss.vcf.gridss_RPostProcess.bedpe and confirmed that all of the second column (QUAL) are digits. Some are integers, but most are floats. Since line 387 of Event.java is: int p1 = Integer.parseInt(bits[1]); I guess there is an issue ... floats in the QUAL col, or is it that our file isn't a bedpe file, or is it that this is an error in clove?
asked Mar 23, 2020 LizzyM 6.1k points
0 votes
1 answer 9 views
9 views
I need to know how to print all palindrome permutations of a string in Java.
asked Oct 4, 2020 Daniel Anderson 4k points
0 votes
1 answer 10 views
10 views
I need to know how to remove the first cgaracter of a string in Java.
asked Sep 25, 2020 Daniel Anderson 4k points
0 votes
1 answer 10 views
0 votes
1 answer 5 views
5 views
Problem: Hi there! I just got an assignment in which I had to remove the first and last character from a string in Java. I did the task using substrings. I want to know what the simplest way is to do so? Also, mention other alternatives to using the substring method. Thanks!
asked 6 days ago Code Learner 5.1k points
0 votes
1 answer 6 views
6 views
I need to know how to print duplicate characters from string in Java.
asked Oct 3, 2020 Daniel Anderson 4k points
0 votes
1 answer 15 views
15 views
I am having problem or facing the issue removing last character from string in JavaScript.
asked Sep 29, 2020 Daniel Anderson 4k points
0 votes
1 answer 15 views
15 views
I am finding the answers in several blog for removing particular character from string in java.
asked Sep 29, 2020 Daniel Anderson 4k points
0 votes
1 answer 10 views
10 views
I am finding difficulty with non repeated characters in a string in Java.
asked Sep 26, 2020 Daniel Anderson 4k points
0 votes
1 answer 17 views
17 views
I need to know how to extract numbers from alphanumeric string in Java.
asked Sep 26, 2020 Daniel Anderson 4k points