From 2d6ed6d0832b12b7463f391b80a2fbd9dd9466ae Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 1 Jul 2013 07:56:02 -0500 Subject: fixed some issues & added a new array init --- java.html.markdown | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/java.html.markdown b/java.html.markdown index 3208971d..e0ef49c3 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -19,10 +19,10 @@ Java is a general-purpose, concurrent, class-based, object-oriented computer pro Multi-line comments look like this. */ -// Import Packages +// Import ArrayList class inside of the java.util package import java.util.ArrayList; -// Import all "sub-packages" -import java.lang.Math.*; +// Import all classes inside of java.lang package +import java.lang.*; // Inside of the learnjava class, is your program's // starting point. The main method. @@ -93,6 +93,9 @@ int [] intArray = new int[10]; String [] stringArray = new String[1]; boolean [] booleanArray = new boolean[100]; +// Another way to declare & initialize an array +int [] y = {9000, 1000, 1337}; + // Indexing an array - Accessing an element System.out.println("intArray @ 0: "+intArray[0]); @@ -118,9 +121,9 @@ int i1 = 1, i2 = 2; // Shorthand for multiple declarations // Arithmetic is straightforward System.out.println("1+2 = "+(i1 + i2)); // => 3 -System.out.println("1+2 = "+(i2 - i1)); // => 1 -System.out.println("1+2 = "+(i2 * i1)); // => 2 -System.out.println("1+2 = "+(i1 / i2)); // => 0 (0.5, but truncated towards 0) +System.out.println("1-2 = "+(i2 - i1)); // => 1 +System.out.println("1*2 = "+(i2 * i1)); // => 2 +System.out.println("1/2 = "+(i1 / i2)); // => 0 (0.5, but truncated towards 0) // Modulo System.out.println("11%3 = "+(11 % 3)); // => 2 -- cgit v1.2.3 From 1863a5de878d527ade6d15f0e4c4ad92695c054d Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 1 Jul 2013 07:59:59 -0500 Subject: Text fix. --- java.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java.html.markdown b/java.html.markdown index e0ef49c3..587e793e 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -121,8 +121,8 @@ int i1 = 1, i2 = 2; // Shorthand for multiple declarations // Arithmetic is straightforward System.out.println("1+2 = "+(i1 + i2)); // => 3 -System.out.println("1-2 = "+(i2 - i1)); // => 1 -System.out.println("1*2 = "+(i2 * i1)); // => 2 +System.out.println("2-1 = "+(i2 - i1)); // => 1 +System.out.println("2*1 = "+(i2 * i1)); // => 2 System.out.println("1/2 = "+(i1 / i2)); // => 0 (0.5, but truncated towards 0) // Modulo -- cgit v1.2.3 From 9da1289d91d710dcd9157e364a32b0ba7928c679 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 1 Jul 2013 09:32:19 -0500 Subject: Added code conventions link --- java.html.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java.html.markdown b/java.html.markdown index 587e793e..3d2e6bbe 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -349,4 +349,6 @@ Other Topics To Research: * [Generics](http://docs.oracle.com/javase/tutorial/java/generics/index.html) +* [Java Code Conventions](http://www.oracle.com/technetwork/java/codeconv-138413.html) + * The links provided are just to get an understanding of the topic, feel free to google and find specific examples -- cgit v1.2.3