Created
August 1, 2013 19:56
-
-
Save dhust/6134658 to your computer and use it in GitHub Desktop.
print()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Printing text | |
System.out.print("Hello class"); | |
// Printing a String | |
String name = "Dexter"; | |
System.out.print("Hello " + name); | |
// Printing an integer | |
int number = 8; | |
System.out.print("My number is " + number); | |
// Printing a decimal | |
float number = 8.54f; | |
System.out.print("My number is " + number); | |
//Printing complex text | |
Scanner inputInt = new Scanner(System.in); | |
int userNumber, userNumber2; | |
System.out.print("Please enter a number: "); | |
userNumber = inputInt.nextInt(); | |
System.out.print("Please enter a number: "); | |
userNumber2 = inputInt.nextInt(); | |
System.out.print("The numbers are " + userNumber + " and " + userNumber2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment