We have learned how to create variables in Java
Now we are gonna learn how to print these variables values on the screen
First of all we need a java file, java class with same name , and a main method
public class first{
public static void main(String[] args) {
}
}
After we write these, we need to add this method :
System.out.println();
public class first{
public static void main(String[] args) {
System.out.println();
}
}
Inside the parentheses, we can write a number or string in double quotation marks "like this"
public class first{
public static void main(String[] args) {
System.out.println("Hello world");
int x = 7;
System.out.println(x);
}
}
Hello world
7
If you want to print multiple variables with multiple types
You should put "+" sign between the variables