Skip to content

Instantly share code, notes, and snippets.

@dhust
Created August 1, 2013 19:56
Show Gist options
  • Save dhust/6134658 to your computer and use it in GitHub Desktop.
Save dhust/6134658 to your computer and use it in GitHub Desktop.
print()
// 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