+ 2

please make me know what is the problem of following code

//Identify words and numbers import java.utl.Scanner; class a { int g; private void character (String g){ g = sc; sc = nextLine(); System.out.println("string"); } } class b { int f; private void number (Integer f){ f = sc; sc = nextInt(); System.out.println("number"); } } public static void main (String[]args){ Scanner sc = new Scanner(System.in); a Scanner sc = new a(); (nextLine()).character(); b Scanner sc = new b(); (nextInt()).number(); }

24th Oct 2017, 9:15 AM
E Vision
E Vision - avatar
3 odpowiedzi
+ 6
24th Oct 2017, 10:04 AM
Limitless
Limitless - avatar
+ 5
I see that this is JAVA, but where did you learn to program? first line utl should be util a Scanner sc = new a(); //???????????????? HOW AND WHY? When you Initialize a new instance you'll need to assign it to a variable like this: a myA = new a(); same with the other few lines in the Main function. The classes are just wrong. Are you mixing Java with Python? Please do the courses again, I'll see what I can do around this code of yours
24th Oct 2017, 9:58 AM
Limitless
Limitless - avatar
+ 2
thank you
25th Oct 2017, 1:29 PM
E Vision
E Vision - avatar