From f2a5bc8a91ab7da393a1c8548956d6e858bf2c11 Mon Sep 17 00:00:00 2001 From: Sean Nam Date: Tue, 3 Jan 2017 00:48:44 -0800 Subject: Updated Java (en-us) to include Input using Scanner and System.in --- java.html.markdown | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 12de0c73..9bb036cd 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -10,6 +10,7 @@ contributors: - ["Rachel Stiyer", "https://github.com/rstiyer"] - ["Michael Dähnert", "https://github.com/JaXt0r"] - ["Rob Rose", "https://github.com/RobRoseKnows"] + - ["Sean Nam", "https://github.com/seannam"] filename: LearnJava.java --- @@ -51,6 +52,14 @@ public class LearnJava { // point. public static void main (String[] args) { + /////////////////////////////////////// + // Input/Output + /////////////////////////////////////// + + /* + * Ouput + */ + // Use System.out.println() to print lines. System.out.println("Hello World!"); System.out.println( @@ -65,6 +74,32 @@ public class LearnJava { // Use System.out.printf() for easy formatted printing. System.out.printf("pi = %.5f", Math.PI); // => pi = 3.14159 + /* + * Input + */ + + // use Scanner to read input + // must import java.util.Scanner; + Scanner scanner = new Scanner(System.in); + + // read string input + String name = scanner.next(); + + // read byte input + byte numByte = scanner.nextByte(); + + // read int input + int numInt = scanner.nextInt(); + + // read long input + float numFloat - scanner.nextFloat(); + + // read double input + double numDouble = scanner.nextDouble(); + + // read boolean input + boolean bool = scanner.nextBoolean(); + /////////////////////////////////////// // Variables /////////////////////////////////////// -- cgit v1.2.3 From 3bfb74042f1bb682e729fc79d017cdbb3c8024ba Mon Sep 17 00:00:00 2001 From: Sean Nam Date: Wed, 8 Feb 2017 23:36:49 -0800 Subject: Changed indentation to 4 spaces --- java.html.markdown | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 9bb036cd..c92c09dc 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -52,13 +52,13 @@ public class LearnJava { // point. public static void main (String[] args) { - /////////////////////////////////////// - // Input/Output - /////////////////////////////////////// + /////////////////////////////////////// + // Input/Output + /////////////////////////////////////// - /* - * Ouput - */ + /* + * Ouput + */ // Use System.out.println() to print lines. System.out.println("Hello World!"); -- cgit v1.2.3 From 52ff8f41e4ef9de074081b5ef22c5dfa4dd86f0a Mon Sep 17 00:00:00 2001 From: Sean Nam Date: Wed, 8 Feb 2017 23:39:49 -0800 Subject: Changed more indentation to 4 spaces --- java.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index c92c09dc..7f224e17 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -75,8 +75,8 @@ public class LearnJava { System.out.printf("pi = %.5f", Math.PI); // => pi = 3.14159 /* - * Input - */ + * Input + */ // use Scanner to read input // must import java.util.Scanner; -- cgit v1.2.3 From 2c2c6e7b15b2dc248ff5c397e235f5c94823c567 Mon Sep 17 00:00:00 2001 From: Sean Nam Date: Sun, 12 Mar 2017 15:26:04 -0700 Subject: Fixed indentation in the java file --- java.html.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index f28e953a..a7060317 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -56,9 +56,9 @@ public class LearnJava { // Input/Output /////////////////////////////////////// - /* - * Ouput - */ + /* + * Ouput + */ // Use System.out.println() to print lines. System.out.println("Hello World!"); @@ -75,8 +75,8 @@ public class LearnJava { System.out.printf("pi = %.5f", Math.PI); // => pi = 3.14159 /* - * Input - */ + * Input + */ // use Scanner to read input // must import java.util.Scanner; -- cgit v1.2.3 From e48049b7922b80829fd13636a5f7e49b60ce76e2 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 23 Mar 2017 11:58:16 -0700 Subject: Replace tabs with 4 spaces in java --- java.html.markdown | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index a7060317..3ec938ef 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -30,13 +30,13 @@ Multi-line comments look like this. * attributes of a Class. * Main attributes: * - * @author Name (and contact information such as email) of author(s). - * @version Current version of the program. - * @since When this part of the program was first added. - * @param For describing the different parameters for a method. - * @return For describing what the method returns. + * @author Name (and contact information such as email) of author(s). + * @version Current version of the program. + * @since When this part of the program was first added. + * @param For describing the different parameters for a method. + * @return For describing what the method returns. * @deprecated For showing the code is outdated or shouldn't be used. - * @see Links to another part of documentation. + * @see Links to another part of documentation. */ // Import ArrayList class inside of the java.util package @@ -56,9 +56,9 @@ public class LearnJava { // Input/Output /////////////////////////////////////// - /* - * Ouput - */ + /* + * Ouput + */ // Use System.out.println() to print lines. System.out.println("Hello World!"); @@ -78,27 +78,27 @@ public class LearnJava { * Input */ - // use Scanner to read input - // must import java.util.Scanner; - Scanner scanner = new Scanner(System.in); + // use Scanner to read input + // must import java.util.Scanner; + Scanner scanner = new Scanner(System.in); - // read string input - String name = scanner.next(); + // read string input + String name = scanner.next(); - // read byte input - byte numByte = scanner.nextByte(); + // read byte input + byte numByte = scanner.nextByte(); - // read int input - int numInt = scanner.nextInt(); + // read int input + int numInt = scanner.nextInt(); - // read long input - float numFloat - scanner.nextFloat(); + // read long input + float numFloat - scanner.nextFloat(); - // read double input - double numDouble = scanner.nextDouble(); + // read double input + double numDouble = scanner.nextDouble(); - // read boolean input - boolean bool = scanner.nextBoolean(); + // read boolean input + boolean bool = scanner.nextBoolean(); /////////////////////////////////////// // Variables @@ -752,7 +752,7 @@ class Dog extends Animal public void makeSound() { System.out.println("Bark"); - // age = 30; ==> ERROR! age is private to Animal + // age = 30; ==> ERROR! age is private to Animal } // NOTE: You will get an error if you used the -- cgit v1.2.3