[Help] Reading a Char from input and show.

@wje4site (170)
India
December 11, 2010 8:59am CST
Hello Mylot programmers, You may probably have to use code for user to get input from user(keyboard). There maybe many ways. But I am using "findInLine(".")charAt(0)". So I have troubles to use it now. Here below I give the program. On the above method usage it give me NullPointerError. Please give me solution to overcome this. import java.util.Scanner; import static java.lang.System.*; class FillingArray { public static void main(String args[]) { Scanner gi=new Scanner(in); int r,n; int g[]=new int[50]; for(int i=0;i
1 response
• Brazil
4 Jan 11
Well, I really don't get why you using "findInLine(".")" method to get the user input, is it really necessary? And this "ans = ..." line, what is this for? I just remove this "findInLine" (replacing with next()) method and everything works fine, if there is a truly propose to use findInLine let me know. And also remove the ans attribution and declaration lines: The code can be seen here: http://codeviewer.org/view/code:15b6
@wje4site (170)
• India
5 Jan 11
Wow, really thanks. Your code is working simply superb. Thanks a lot friend. I used findInLine() method for many programs and didn't get any errors. But this one gives me somewhat confusion. Really thanks for your help. I may post may same criteria questions too often under java. I request you to help me to solve them. Thanks a lot again :P