Hi im new to Coding with java well just coding in general but how would i do an "if then" kind of thing, i was tryg to have user in put lab and i want
Java
Coder100Like this:
if (something)
{
}
else if (somethinh)
{
}
else
{
}
In your case:
import java.util.Scanner;
class App
{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args)
{
System.out.print("Enter something: ");
String x = sc.nextLine();
if (x == "hi")
{
System.out.println("You said hi!");
}
else if (x == "hello")
{
System.out.println("You said hello!");
}
else
{
System.out.println("You said something3 years ago
leo-ironkeyhere's the docs : )
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html
3 years ago
NicholasWhite6if anyone could help with this that would be great!
3 years ago