Please someone find error in this code. Exception in thread "main" java.lang.NullPointerException | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Please someone find error in this code. Exception in thread "main" java.lang.NullPointerException

https://code.sololearn.com/cbvpqBn0zwXm/?ref=app

21st Jun 2017, 2:35 PM
Aisha Chaudhary
Aisha Chaudhary - avatar
14 Answers
+ 2
the code is probably missing some imports... double check.. I'm sleepy.😴
21st Jun 2017, 3:26 PM
Mr. Yoh So
Mr. Yoh So - avatar
+ 2
sleepy last night.. I didn't see the * on io imports.. Try to specify the exact location or directory of your files.. on PC something like FileReader("c://JavaProjects//filename.txt"); on smartphones, I don't know how to locate the directory, and probably you'll need permissions in accessing the drives..😸.. keep calm and enjoy coding..🏃🏃
21st Jun 2017, 11:45 PM
Mr. Yoh So
Mr. Yoh So - avatar
+ 1
Aisha aa u can observe something is wrong with way u parse argument go to stack overflow u can get this fixed easily
21st Jun 2017, 2:49 PM
chanda venkatesh
chanda venkatesh - avatar
+ 1
Your in.ReadLine() is causing the problem. You can test it by using a Scanner or replace it with an "4"
21st Jun 2017, 2:53 PM
Limitless
Limitless - avatar
+ 1
Paste the error code you get on Eclipse here
21st Jun 2017, 3:34 PM
Limitless
Limitless - avatar
0
what to write instead of in.readLine() ?
21st Jun 2017, 3:00 PM
Aisha Chaudhary
Aisha Chaudhary - avatar
0
What are you trying to achieve with DataInputStream?
21st Jun 2017, 3:02 PM
Limitless
Limitless - avatar
0
it allows an application to read primitive data from the input stream in a machine-independent way
21st Jun 2017, 3:04 PM
Aisha Chaudhary
Aisha Chaudhary - avatar
0
You mean like a file stream?
21st Jun 2017, 3:05 PM
Limitless
Limitless - avatar
0
:/ I prefer using the Scanner class. Just because it will save time for now
21st Jun 2017, 3:19 PM
Limitless
Limitless - avatar
0
program is running fine, I'm getting error when I'm selecting choice 2 i.e. voting. error is in voting func.
21st Jun 2017, 3:26 PM
Aisha Chaudhary
Aisha Chaudhary - avatar
0
Well File not found? Does it work on PC?
21st Jun 2017, 3:28 PM
Limitless
Limitless - avatar
0
Yeah. it is working Only I'm getting error while selecting choice 3 i.e. voting
21st Jun 2017, 3:30 PM
Aisha Chaudhary
Aisha Chaudhary - avatar
0
This would be so perfect in C# tho. Option 1: Ok Option 2: File not Found Option 3: File not Found Option 4: Ok
21st Jun 2017, 3:33 PM
Limitless
Limitless - avatar