+ 1

Why is my code not running

import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); String fn = sc.next(); String sn = sc.next(); String name = fn + sn; System.out.println("name"); } }

6th Apr 2018, 4:08 PM
Ayo Sam
Ayo Sam - avatar
2 odpowiedzi
+ 4
Remove the " at the print statement to print the name variable: System.out.println(name);
6th Apr 2018, 4:11 PM
TurtleShell
TurtleShell - avatar
+ 1
If you do System.out.println("name") you will just print the word name not the String variable name
6th Apr 2018, 10:06 PM
Paul Yan
Paul Yan - avatar