Favouronu Favouronu -4 years ago 134
Java Question

How to use Scanners on users input

I am trying to create a scanner that executes depending on the users input, but it isn't working. This is a sample:

import java.util.Scanner;

public class Test {
public static void main(String[] args) {

System.out.println("Type in:");
System.out.println("Love");
System.out.println("Hate");
System.out.println("What ?");

Scanner c = new Scanner(System.in);
String n = c.nextLine();

System.out.println("You Type in " + n);

if(n == Love) {
System.out.print("Jesus Loves You");
}
}
}


What do you think might be the problem?

Answer Source

You're missing the variable.

function nameIt() {
var name = document.getElementById("name").value;
alert(name);
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download