├── .gitattributes ├── .gitignore ├── Chapter01 ├── 1.2 │ └── HelloWorld.java └── 1.3 │ └── HelloWorld.java ├── Chapter02 ├── 2.1 │ └── Variables.java ├── 2.2 │ └── FloatingPointNumbers.java ├── 2.3 │ └── TheMathLib.java ├── 2.4 │ └── Characters.java └── 2.5 │ └── StringsInJava.java ├── Chapter03 ├── 3.1 │ └── ConditionalStatements2.java ├── 3.2 │ └── ComplexConditionals.java ├── 3.3 │ └── Switcher.java ├── 3.4 │ └── IntroToLoops.java └── 3.5 │ ├── ForLoop.java │ └── WhileLoop.java ├── Chapter04 ├── 4.1 │ └── Alphabet.java ├── 4.2 │ └── ChessBoard.java ├── 4.3 │ └── Echo.java └── 4.4 │ ├── Maps_End.java │ └── Maps_Start.java ├── Chapter05 ├── 5.1 │ ├── TemperatureConverter_Begin.java │ └── TemperatureConverter_End.java └── 5.2 │ ├── AdvancedMethods_Begin.java │ └── AdvancedMethods_End.java ├── Chapter06 ├── 6.1 │ ├── GettingObjectOriented_Begin.java │ ├── GettingObjectOriented_End.java │ └── Person.java └── 6.2 │ ├── GettingObjectOriented_Begin.java │ ├── GettingObjectOriented_End.java │ ├── Person_Begin.java │ └── Person_End.java ├── Chapter07 ├── 7.1 End │ ├── Book.java │ ├── Inheritance.java │ ├── Literature.java │ └── Poem.java ├── 7.1 Start │ ├── Book.java │ ├── Inheritance.java │ └── Poem.java ├── 7.2 End │ ├── Book.java │ ├── Inheritance.java │ ├── Literature.java │ └── Poem.java └── 7.2 Start │ ├── Book.java │ ├── Inheritance.java │ ├── Literature.java │ └── Poem.java ├── Chapter08 ├── 8.1 │ └── DatesAndTimes.java ├── 8.2 │ ├── CustomPrinter.java │ ├── Strings_End.java │ └── Strings_Start.java ├── 8.3 │ ├── Exceptions_End.java │ └── Exceptions_Start.java ├── 8.4 │ ├── MyClass.java │ └── TheObjectClass.java └── 8.5 │ └── ThePrimitiveClasses.java ├── Chapter09 ├── 9.1 │ ├── WritingToFiles_End.java │ └── WritingToFiles_Start.java ├── 9.2 │ ├── InputAndOutput_End.java │ └── InputAndOutput_Start.java ├── 9.3 End │ ├── Car.java │ ├── DeSerialize.java │ └── Serialize.java └── 9.3 Start │ └── Car.java ├── Chapter10 ├── GUI.java └── MyGUI.java ├── Chapter11 ├── 11.1 │ ├── LoadingAnXMLFile_End.java │ ├── LoadingAnXMLFile_Start.java │ └── cars.xml ├── 11.2 │ ├── Car.java │ ├── ReadingXML_End.java │ ├── ReadingXML_Start.java │ └── cars.xml └── 11.3 │ ├── WritingXML_End.java │ ├── WritingXML_Start.java │ └── cars.xml ├── LICENSE ├── Labs ├── Java Programming for Beginner - Lab 02.pdf ├── Java Programming for Beginner - Lab 03.pdf ├── Java Programming for Beginner - Lab 04.pdf ├── Java Programming for Beginner - Lab 05.pdf ├── Java Programming for Beginner - Lab 06.pdf ├── Java Programming for Beginner - Lab 07.pdf ├── Java Programming for Beginner - Lab 08.pdf ├── Java Programming for Beginner - Lab 09.pdf ├── Java Programming for Beginner - Lab 10.pdf ├── Java Programming for Beginner - Lab 11.pdf └── Java Programming for Beginner - Lab01.pdf ├── README.md └── Solutions ├── Java Programming for Beginner - Lab 01 Solutions.pdf ├── Java Programming for Beginner - Lab 02 Solutions.pdf ├── Java Programming for Beginner - Lab 03 Solutions.pdf ├── Java Programming for Beginner - Lab 04 Solutions.pdf ├── Java Programming for Beginner - Lab 05 Solutions.pdf ├── Java Programming for Beginner - Lab 06 Solutions.pdf ├── Java Programming for Beginner - Lab 07 Solutions.pdf ├── Java Programming for Beginner - Lab 08 Solutions.pdf ├── Java Programming for Beginner - Lab 09 Solutions.pdf ├── Java Programming for Beginner - Lab 10 Solutions.pdf └── Java Programming for Beginner - Lab 11 Solutions.pdf /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Chapter01/1.2/HelloWorld.java: -------------------------------------------------------------------------------- 1 | 2 | public class HelloWorld { 3 | public static void main(String[] args) { 4 | System.out.println("Hello World"); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Chapter01/1.3/HelloWorld.java: -------------------------------------------------------------------------------- 1 | 2 | public class HelloWorld { 3 | public static void main(String[] args) { 4 | System.out.println("Hello World"); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Chapter02/2.1/Variables.java: -------------------------------------------------------------------------------- 1 | package variables; 2 | 3 | public class Variables { 4 | 5 | public static void main(String[] args) { 6 | 7 | int x; 8 | int y; 9 | 10 | x = 10; 11 | y = 5; 12 | 13 | //2147483647 14 | //-2147483648 15 | 16 | System.out.println(x+y); 17 | System.out.println(x-y); 18 | System.out.println(x*y); 19 | System.out.println(x/y); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Chapter02/2.2/FloatingPointNumbers.java: -------------------------------------------------------------------------------- 1 | 2 | package floatingpointnumbers; 3 | 4 | public class FloatingPointNumbers { 5 | public static void main(String[] args) { 6 | 7 | int iNumber1 = 5; 8 | int iNumber2 = 6; 9 | float fNumber = (float)iNumber1/iNumber2; 10 | 11 | System.out.println(fNumber); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Chapter02/2.3/TheMathLib.java: -------------------------------------------------------------------------------- 1 | package themathlib; 2 | 3 | import java.lang.Math; 4 | 5 | public class TheMathLib { 6 | public static void main(String[] args) { 7 | double number = 4.321; 8 | number = Math.pow(number, 4.0); 9 | System.out.println(number); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Chapter02/2.4/Characters.java: -------------------------------------------------------------------------------- 1 | package characters; 2 | 3 | public class Characters { 4 | public static void main(String[] args) { 5 | char character1 = 'H'; 6 | char character2 = 9; 7 | char character3 = 9; 8 | char character4 = 9; 9 | char character5 = 'o'; 10 | 11 | System.out.print(character1); 12 | System.out.print(character2); 13 | System.out.print(character3); 14 | System.out.print(character4); 15 | System.out.println(character5); 16 | } 17 | } -------------------------------------------------------------------------------- /Chapter02/2.5/StringsInJava.java: -------------------------------------------------------------------------------- 1 | package stringsinjava; 2 | 3 | public class StringsInJava { 4 | public static void main(String[] args) { 5 | /*char c = 'c'; 6 | String s1 = "stringone"; 7 | String s2 = "stringtwo"; 8 | String s3 = s1 + s2 + "LIT"; 9 | 10 | s3 = s3.toUpperCase(); 11 | 12 | System.out.println( s3.replace('G','o') ); 13 | System.out.println( s3 );*/ 14 | 15 | String s = "The program says: \\ \"Hello World\""; 16 | System.out.println(s); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Chapter03/3.1/ConditionalStatements2.java: -------------------------------------------------------------------------------- 1 | 2 | package conditionalstatements2; 3 | 4 | import java.util.*; 5 | 6 | public class ConditionalStatements2 { 7 | 8 | public static void main(String[] args) { 9 | Scanner reader = new Scanner(System.in); 10 | System.out.println("Input now: "); 11 | int input = reader.nextInt(); 12 | 13 | if(input > 10) 14 | { 15 | System.out.println("MORE!"); 16 | } 17 | else 18 | { 19 | System.out.println("LESS!"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Chapter03/3.2/ComplexConditionals.java: -------------------------------------------------------------------------------- 1 | 2 | package complexconditionals; 3 | 4 | import java.util.*; 5 | 6 | public class ComplexConditionals { 7 | public static void main(String[] args) { 8 | Scanner reader = new Scanner(System.in); 9 | String input = reader.next(); 10 | String sOne = "abc"; 11 | String sTwo = "z"; 12 | 13 | boolean bool1 = input.contains(sOne); 14 | boolean bool2 = input.contains(sTwo); 15 | 16 | if((bool1 || bool2) && false) 17 | { 18 | System.out.println("TRUE"); 19 | } 20 | else 21 | { 22 | System.out.println("FALSE"); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter03/3.3/Switcher.java: -------------------------------------------------------------------------------- 1 | package switcher; 2 | 3 | public class Switcher { 4 | public static void main(String[] args) { 5 | int x = 7; 6 | 7 | switch(x) 8 | { 9 | case 1: case 5: case 7: 10 | System.out.println("RED"); 11 | break; 12 | case 2: 13 | System.out.println("BLUE"); 14 | break; 15 | case 3: 16 | System.out.println("GREEN"); 17 | break; 18 | default: 19 | System.out.println("NONE"); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Chapter03/3.4/IntroToLoops.java: -------------------------------------------------------------------------------- 1 | package introtoloops; 2 | 3 | import java.util.*; 4 | 5 | public class IntroToLoops { 6 | public static void main(String[] args) { 7 | Scanner reader = new Scanner(System.in); 8 | 9 | String input; 10 | String all = ""; 11 | 12 | do 13 | { 14 | input = reader.nextLine(); 15 | all += input; 16 | } while(!input.equals("STOP")); 17 | 18 | System.out.println(all); 19 | } 20 | } -------------------------------------------------------------------------------- /Chapter03/3.5/ForLoop.java: -------------------------------------------------------------------------------- 1 | package forloops; 2 | 3 | public class ForLoops { 4 | public static void main(String[] args) { 5 | for(int i = 1; i <= 100; i++) 6 | { 7 | System.out.println(i); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /Chapter03/3.5/WhileLoop.java: -------------------------------------------------------------------------------- 1 | package forloops; 2 | 3 | public class ForLoops { 4 | public static void main(String[] args) { 5 | int i = 1; 6 | while(i <= 100) 7 | { 8 | System.out.println(i); 9 | i++; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Chapter04/4.1/Alphabet.java: -------------------------------------------------------------------------------- 1 | package alphabet; 2 | 3 | import java.util.*; 4 | 5 | public class Alphabet { 6 | public static void main(String[] args) { 7 | //97 8 | char[] alpha = new char[26]; 9 | 10 | for(int i = 0; i < 26; i++) 11 | { 12 | alpha[i] = (char)(97 + i); 13 | } 14 | 15 | System.out.println(Arrays.toString(alpha)); 16 | } 17 | } -------------------------------------------------------------------------------- /Chapter04/4.2/ChessBoard.java: -------------------------------------------------------------------------------- 1 | package chessboard; 2 | 3 | import java.util.*; 4 | 5 | public class ChessBoard { 6 | public static void main(String[] args) { 7 | int boardDim = 8; 8 | char[][] board = new char[boardDim][boardDim]; 9 | boolean isWhite = false; 10 | 11 | for(int y = 0; y < board.length; y++) 12 | { 13 | isWhite = !isWhite; 14 | for(int x = 0; x < board[y].length; x++) 15 | { 16 | if(isWhite) board[y][x] = 'W'; 17 | if(!isWhite) board[y][x] = 'B'; 18 | isWhite = !isWhite; 19 | } 20 | } 21 | 22 | for(int i = 0; i < board.length; i++) 23 | { 24 | System.out.println(Arrays.toString(board[i])); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Chapter04/4.3/Echo.java: -------------------------------------------------------------------------------- 1 | package echo; 2 | 3 | import java.util.*; 4 | 5 | public class Echo { 6 | public static void main(String[] args) { 7 | Scanner reader = new Scanner(System.in); 8 | ArrayList memory = new ArrayList(); 9 | 10 | while(true) 11 | { 12 | memory.add(reader.nextLine()); 13 | 14 | if((memory.get(memory.size()-1)).equals("CLEAR")) { 15 | memory.clear(); 16 | } 17 | else { 18 | if((memory.get(memory.size()-1)).equals("END")) 19 | break; 20 | } 21 | 22 | System.out.println(memory.toString()); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Chapter04/4.4/Maps_End.java: -------------------------------------------------------------------------------- 1 | package maps; 2 | 3 | import java.util.*; 4 | 5 | public class Maps { 6 | public static void main(String[] args) { 7 | String[] allNames = 8 | // 9 | {"Jane", "Addams", 10 | "Muhammad", "Ali", 11 | "Stephen", "Ambrose", 12 | "Louis", "Armstrong", 13 | "Joan", "Baez", 14 | "Josephine", "Baker", 15 | "Eleanor", "Roosevelt", 16 | "Frank", "Sinatra", 17 | }; 18 | // 19 | String[] firstNames = new String[allNames.length/2]; 20 | String[] lastNames = new String[allNames.length/2]; 21 | for(int i = 0; i < allNames.length; i++) 22 | { 23 | /*This if statement checks if we are in an EVEN NUMBERED iteration 24 | % is the "mod" or "modulus" operator... 25 | it returns the remainder after we divide number1 by number2)*/ 26 | if(i % 2 == 0) 27 | { 28 | //We are in an even number iteration - looking at a first name 29 | firstNames[i/2] = allNames[i]; 30 | } 31 | else 32 | { 33 | //We are in an odd number iteration - looking at a last name 34 | lastNames[i/2] = allNames[i]; 35 | } 36 | } 37 | 38 | Map famousPeople = new HashMap<>(); 39 | for(int i = 0; i < lastNames.length; i++) 40 | { 41 | famousPeople.put(lastNames[i],firstNames[i]); 42 | } 43 | 44 | System.out.println(famousPeople.get("Sinatra")); 45 | } 46 | } -------------------------------------------------------------------------------- /Chapter04/4.4/Maps_Start.java: -------------------------------------------------------------------------------- 1 | package maps; 2 | 3 | import java.util.*; 4 | 5 | public class Maps { 6 | public static void main(String[] args) { 7 | String[] allNames = 8 | // 9 | {"Jane", "Addams", 10 | "Muhammad", "Ali", 11 | "Stephen", "Ambrose", 12 | "Louis", "Armstrong", 13 | "Joan", "Baez", 14 | "Josephine", "Baker", 15 | "Eleanor", "Roosevelt", 16 | "Frank", "Sinatra", 17 | }; 18 | // 19 | String[] firstNames = new String[allNames.length/2]; 20 | String[] lastNames = new String[allNames.length/2]; 21 | for(int i = 0; i < allNames.length; i++) 22 | { 23 | /*This if statement checks if we are in an EVEN NUMBERED iteration 24 | % is the "mod" or "modulus" operator... 25 | it returns the remainder after we divide number1 by number2)*/ 26 | if(i % 2 == 0) 27 | { 28 | //We are in an even number iteration - looking at a first name 29 | firstNames[i/2] = allNames[i]; 30 | } 31 | else 32 | { 33 | //We are in an odd number iteration - looking at a last name 34 | lastNames[i/2] = allNames[i]; 35 | } 36 | } 37 | 38 | System.out.println(Arrays.toString(firstNames)); 39 | System.out.println(Arrays.toString(lastNames)); 40 | } 41 | } -------------------------------------------------------------------------------- /Chapter05/5.1/TemperatureConverter_Begin.java: -------------------------------------------------------------------------------- 1 | package temperatureconverter; 2 | 3 | import java.util.*; 4 | 5 | // F to C: ((t-32.0f)*5.0f)/9.0f 6 | // C to K: t+273.15f 7 | // K to F: (((t-273.15f)*9.0f)/5.0f)+32.0f 8 | 9 | public class TemperatureConverter { 10 | public static void main(String[] args) { 11 | Scanner reader = new Scanner(System.in); 12 | char inputType; 13 | char outputType; 14 | float inputValue; 15 | float returnValue; 16 | 17 | System.out.print("Input type (F/C/K): "); 18 | inputType = reader.next().charAt(0); 19 | System.out.print("Output type (F/C/K): "); 20 | outputType = reader.next().charAt(0); 21 | System.out.print("Temperature: "); 22 | inputValue = reader.nextFloat(); 23 | 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /Chapter05/5.1/TemperatureConverter_End.java: -------------------------------------------------------------------------------- 1 | package temperatureconverter; 2 | 3 | import java.util.*; 4 | 5 | // F to C: ((t-32.0f)*5.0f)/9.0f 6 | // C to K: t+273.15f 7 | // K to F: (((t-273.15f)*9.0f)/5.0f)+32.0f 8 | 9 | public class TemperatureConverter { 10 | public static void main(String[] args) { 11 | Scanner reader = new Scanner(System.in); 12 | char inputType; 13 | char outputType; 14 | float inputValue; 15 | float returnValue; 16 | 17 | System.out.print("Input type (F/C/K): "); 18 | inputType = reader.next().charAt(0); 19 | System.out.print("Output type (F/C/K): "); 20 | outputType = reader.next().charAt(0); 21 | System.out.print("Temperature: "); 22 | inputValue = reader.nextFloat(); 23 | 24 | switch(inputType) 25 | { 26 | case 'F': 27 | inputValue = fToC(inputValue); 28 | break; 29 | case 'C': 30 | break; 31 | case 'K': 32 | inputValue = fToC(kToF(inputValue)); 33 | break; 34 | default: 35 | System.exit(1); 36 | } 37 | 38 | switch(outputType) 39 | { 40 | case 'F': 41 | inputValue = kToF(cToK(inputValue)); 42 | break; 43 | case 'C': 44 | break; 45 | case 'K': 46 | inputValue = cToK(inputValue); 47 | break; 48 | default: 49 | System.exit(1); 50 | } 51 | 52 | System.out.println(inputValue); 53 | } 54 | 55 | public static float fToC(float fVal) 56 | { 57 | return ((fVal-32.0f)*5.0f)/9.0f; 58 | } 59 | public static float kToF(float kVal) 60 | { 61 | return (((kVal-273.15f)*9.0f)/5.0f)+32.0f; 62 | } 63 | public static float cToK(float cVal) 64 | { 65 | return cVal+273.15f; 66 | } 67 | } -------------------------------------------------------------------------------- /Chapter05/5.2/AdvancedMethods_Begin.java: -------------------------------------------------------------------------------- 1 | package advancedmethods; 2 | 3 | public class AdvancedMethods { 4 | public static void main(String[] args) { 5 | int[] x = 5; 6 | 7 | magic(x); 8 | 9 | System.out.println("main: " + x); 10 | } 11 | 12 | public static void magic(int input) 13 | { 14 | input += 10; 15 | } 16 | } -------------------------------------------------------------------------------- /Chapter05/5.2/AdvancedMethods_End.java: -------------------------------------------------------------------------------- 1 | package advancedmethods; 2 | 3 | import java.util.*; 4 | 5 | public class AdvancedMethods { 6 | public static void main(String[] args) { 7 | int[] x = {5,4,3,2,1}; 8 | 9 | magic(x); 10 | 11 | System.out.println("main: " + Arrays.toString(x)); 12 | } 13 | 14 | public static void magic(int input) 15 | { 16 | input += 10; 17 | } 18 | public static void magic(int[] input) 19 | { 20 | for(int i = 0; i < input.length; i++) 21 | input[i] += 10; 22 | } 23 | } -------------------------------------------------------------------------------- /Chapter06/6.1/GettingObjectOriented_Begin.java: -------------------------------------------------------------------------------- 1 | package gettingobjectoriented; 2 | 3 | import java.util.*; 4 | 5 | public class GettingObjectOriented { 6 | public static void main(String[] args) { 7 | Scanner reader = new Scanner(System.in); 8 | 9 | System.out.println(reader.next()); 10 | } 11 | } -------------------------------------------------------------------------------- /Chapter06/6.1/GettingObjectOriented_End.java: -------------------------------------------------------------------------------- 1 | package gettingobjectoriented; 2 | 3 | import java.util.*; 4 | 5 | public class GettingObjectOriented { 6 | public static void main(String[] args) { 7 | Person john = new Person(); 8 | john.firstName = "John"; 9 | john.lastName = "Doe"; 10 | john.birthday = new GregorianCalendar(1988,1,5); 11 | 12 | System.out.println(john.age(new GregorianCalendar())); 13 | } 14 | } -------------------------------------------------------------------------------- /Chapter06/6.1/Person.java: -------------------------------------------------------------------------------- 1 | package gettingobjectoriented; 2 | 3 | import java.util.*; 4 | 5 | public class Person { 6 | public String firstName; 7 | public String lastName; 8 | public Calendar birthday; 9 | 10 | public String fullName() 11 | { 12 | return firstName + " " + lastName; 13 | } 14 | 15 | public int age(Calendar today) 16 | { 17 | return today.get(Calendar.YEAR) - birthday.get(Calendar.YEAR); 18 | } 19 | } -------------------------------------------------------------------------------- /Chapter06/6.2/GettingObjectOriented_Begin.java: -------------------------------------------------------------------------------- 1 | package gettingobjectoriented; 2 | 3 | import java.util.*; 4 | 5 | public class GettingObjectOriented { 6 | public static void main(String[] args) { 7 | Person john = new Person(); 8 | john.firstName = "John"; 9 | john.lastName = "Doe"; 10 | john.birthday = new GregorianCalendar(1988,1,5); 11 | 12 | System.out.println( 13 | "Hello my name is " + 14 | john.fullName() + 15 | ". I am " + 16 | john.age(new GregorianCalendar()) + 17 | " years old."); 18 | } 19 | } -------------------------------------------------------------------------------- /Chapter06/6.2/GettingObjectOriented_End.java: -------------------------------------------------------------------------------- 1 | package gettingobjectoriented; 2 | 3 | import java.util.*; 4 | 5 | public class GettingObjectOriented { 6 | public static void main(String[] args) { 7 | Person john = new Person("John", "Doe", new GregorianCalendar(1988,1,5)); 8 | //Person john = new Person("John", "Doe"); 9 | //Person john = new Person(); 10 | 11 | System.out.println( 12 | "Hello my name is " + 13 | john.fullName() + 14 | ". I am " + 15 | john.age(new GregorianCalendar()) + 16 | " years old."); 17 | } 18 | } -------------------------------------------------------------------------------- /Chapter06/6.2/Person_Begin.java: -------------------------------------------------------------------------------- 1 | package gettingobjectoriented; 2 | 3 | import java.util.*; 4 | 5 | public class Person { 6 | public String firstName; 7 | public String lastName; 8 | public Calendar birthday; 9 | 10 | public String fullName() 11 | { 12 | return firstName + " " + lastName; 13 | } 14 | 15 | public int age(Calendar today) 16 | { 17 | return today.get(Calendar.YEAR) - birthday.get(Calendar.YEAR); 18 | } 19 | } -------------------------------------------------------------------------------- /Chapter06/6.2/Person_End.java: -------------------------------------------------------------------------------- 1 | package gettingobjectoriented; 2 | 3 | import java.util.*; 4 | 5 | public class Person { 6 | private String firstName; 7 | private String lastName; 8 | private Calendar birthday; 9 | 10 | public Person() 11 | { 12 | firstName = ""; 13 | lastName = ""; 14 | birthday = new GregorianCalendar(); 15 | } 16 | public Person(String firstName, String lastName) 17 | { 18 | this.firstName = firstName; 19 | this.lastName = lastName; 20 | this.birthday = new GregorianCalendar(); 21 | } 22 | public Person(String firstName, String lastName, Calendar birthday) 23 | { 24 | this.firstName = firstName; 25 | this.lastName = lastName; 26 | this.birthday = birthday; 27 | } 28 | 29 | public String fullName() 30 | { 31 | return firstName + " " + lastName; 32 | } 33 | 34 | public int age(Calendar today) 35 | { 36 | return today.get(Calendar.YEAR) - birthday.get(Calendar.YEAR); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Chapter07/7.1 End/Book.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Book extends Literature { 3 | private String publisher; 4 | private String genre; 5 | 6 | public Book(String title, String author, String publisher, String genre) 7 | { 8 | super(title, author); 9 | this.publisher = publisher; 10 | this.genre = genre; 11 | } 12 | 13 | @Override public void Print() 14 | { 15 | super.Print(); 16 | System.out.println("\tPublished By: " + publisher); 17 | System.out.println("\tIs A: " + genre); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter07/7.1 End/Inheritance.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | 3 | public class Inheritance { 4 | public static void main(String[] args) { 5 | Book a = new Book( 6 | "The Lord Of The Rings", 7 | "J.R.R. Tolkein", 8 | "George Allen and Unwin", 9 | "Fantasy"); 10 | Poem b = new Poem( 11 | "The Iliad", 12 | "Homer", 13 | "Dactylic Hexameter"); 14 | 15 | Literature[] lits = new Literature[5]; 16 | lits[0] = a; 17 | lits[1] = b; 18 | lits[2] = a; 19 | lits[3] = b; 20 | lits[4] = a; 21 | 22 | for(int i = 0; i < lits.length; i++) 23 | { 24 | lits[i].Print(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter07/7.1 End/Literature.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Literature { 3 | protected String title; 4 | protected String author; 5 | 6 | public Literature(String title, String author) 7 | { 8 | this.title = title; 9 | this.author = author; 10 | } 11 | 12 | public void Print() 13 | { 14 | System.out.println(title); 15 | System.out.println("\tWritten By: " + author); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Chapter07/7.1 End/Poem.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Poem extends Literature { 3 | private String style; 4 | 5 | public Poem(String title, String author, String style) 6 | { 7 | super(title, author); 8 | this.style = style; 9 | } 10 | 11 | @Override public void Print() 12 | { 13 | System.out.println("POEM: " + title); 14 | System.out.println("\tWritten By: " + author); 15 | System.out.println("\tIn The Style Of: " + style); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Chapter07/7.1 Start/Book.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Book { 3 | private String title; 4 | private String author; 5 | private String publisher; 6 | private String genre; 7 | 8 | public Book(String title, String author, String publisher, String genre) 9 | { 10 | this.title = title; 11 | this.author = author; 12 | this.publisher = publisher; 13 | this.genre = genre; 14 | } 15 | 16 | public void Print() 17 | { 18 | System.out.println(title); 19 | System.out.println("\tWritten By: " + author); 20 | System.out.println("\tPublished By: " + publisher); 21 | System.out.println("\tIs A: " + genre); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Chapter07/7.1 Start/Inheritance.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | 3 | public class Inheritance { 4 | public static void main(String[] args) { 5 | Book a = new Book( 6 | "The Lord Of The Rings", 7 | "J.R.R. Tolkein", 8 | "George Allen and Unwin", 9 | "Fantasy"); 10 | Poem b = new Poem( 11 | "The Iliad", 12 | "Homer", 13 | "Dactylic Hexameter"); 14 | 15 | a.Print(); 16 | b.Print(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Chapter07/7.1 Start/Poem.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Poem { 3 | private String title; 4 | private String author; 5 | private String style; 6 | 7 | public Poem(String title, String author, String style) 8 | { 9 | this.title = title; 10 | this.author = author; 11 | this.style = style; 12 | } 13 | 14 | public void Print() 15 | { 16 | System.out.println(title); 17 | System.out.println("\tWritten By: " + author); 18 | System.out.println("\tIn The Style Of: " + style); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Chapter07/7.2 End/Book.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Book extends Literature { 3 | private String publisher; 4 | private String genre; 5 | 6 | public Book(String title, String author, String publisher, String genre) 7 | { 8 | this.title = title; 9 | this.author = author; 10 | this.publisher = publisher; 11 | this.genre = genre; 12 | } 13 | 14 | @Override public void Print() 15 | { 16 | super.Print(); 17 | System.out.println("\tPublished By: " + publisher); 18 | System.out.println("\tIs A: " + genre); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Chapter07/7.2 End/Inheritance.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | 3 | public class Inheritance { 4 | public static void main(String[] args) { 5 | Book a = new Book( 6 | "The Lord Of The Rings", 7 | "J.R.R. Tolkein", 8 | "George Allen and Unwin", 9 | "Fantasy"); 10 | Poem b = new Poem( 11 | "The Iliad", 12 | "Homer", 13 | "Dactylic Hexameter"); 14 | 15 | Literature[] lits = new Literature[5]; 16 | lits[0] = a; 17 | lits[1] = b; 18 | lits[2] = a; 19 | lits[3] = b; 20 | lits[4] = a; 21 | 22 | for(int i = 0; i < lits.length; i++) 23 | { 24 | lits[i].Print(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter07/7.2 End/Literature.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public abstract class Literature { 3 | protected String title; 4 | protected String author; 5 | 6 | public void Print() 7 | { 8 | System.out.println(title); 9 | System.out.println("\tWritten By: " + author); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Chapter07/7.2 End/Poem.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Poem extends Literature { 3 | private String style; 4 | 5 | public Poem(String title, String author, String style) 6 | { 7 | this.title = title; 8 | this.author = author; 9 | this.style = style; 10 | } 11 | 12 | @Override public void Print() 13 | { 14 | System.out.println("POEM: " + title); 15 | System.out.println("\tWritten By: " + author); 16 | System.out.println("\tIn The Style Of: " + style); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Chapter07/7.2 Start/Book.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Book extends Literature { 3 | private String publisher; 4 | private String genre; 5 | 6 | public Book(String title, String author, String publisher, String genre) 7 | { 8 | super(title, author); 9 | this.publisher = publisher; 10 | this.genre = genre; 11 | } 12 | 13 | @Override public void Print() 14 | { 15 | super.Print(); 16 | System.out.println("\tPublished By: " + publisher); 17 | System.out.println("\tIs A: " + genre); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter07/7.2 Start/Inheritance.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | 3 | public class Inheritance { 4 | public static void main(String[] args) { 5 | Book a = new Book( 6 | "The Lord Of The Rings", 7 | "J.R.R. Tolkein", 8 | "George Allen and Unwin", 9 | "Fantasy"); 10 | Poem b = new Poem( 11 | "The Iliad", 12 | "Homer", 13 | "Dactylic Hexameter"); 14 | 15 | Literature[] lits = new Literature[5]; 16 | lits[0] = a; 17 | lits[1] = b; 18 | lits[2] = a; 19 | lits[3] = b; 20 | lits[4] = a; 21 | 22 | for(int i = 0; i < lits.length; i++) 23 | { 24 | lits[i].Print(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter07/7.2 Start/Literature.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Literature { 3 | protected String title; 4 | protected String author; 5 | 6 | public Literature(String title, String author) 7 | { 8 | this.title = title; 9 | this.author = author; 10 | } 11 | 12 | public void Print() 13 | { 14 | System.out.println(title); 15 | System.out.println("\tWritten By: " + author); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Chapter07/7.2 Start/Poem.java: -------------------------------------------------------------------------------- 1 | package inheritance; 2 | public class Poem extends Literature { 3 | private String style; 4 | 5 | public Poem(String title, String author, String style) 6 | { 7 | super(title, author); 8 | this.style = style; 9 | } 10 | 11 | @Override public void Print() 12 | { 13 | System.out.println("POEM: " + title); 14 | System.out.println("\tWritten By: " + author); 15 | System.out.println("\tIn The Style Of: " + style); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Chapter08/8.1/DatesAndTimes.java: -------------------------------------------------------------------------------- 1 | package DatesAndTimes; 2 | 3 | import java.util.*; 4 | 5 | public class DatesAndTimes { 6 | Calendar now = Calendar.getInstance(); 7 | 8 | now.setTimeInMillis(0); 9 | 10 | System.out.println(now.get(Calendar.MONTH) + 1); 11 | System.out.println(now.get(Calendar.DAY_OF_MONTH)); 12 | System.out.println(now.get(Calendar.YEAR)); 13 | } 14 | -------------------------------------------------------------------------------- /Chapter08/8.2/CustomPrinter.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | public class CustomPrinter { 4 | private String formatString; 5 | 6 | public CustomPrinter(String format) 7 | { 8 | formatString = format; 9 | } 10 | 11 | public void println(String input) 12 | { 13 | String formatted = String.format(formatString, input); 14 | System.out.println(formatted); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Chapter08/8.2/Strings_End.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | public class Strings { 4 | 5 | public static void main(String[] args) { 6 | CustomPrinter printer = new CustomPrinter("> > %s < <"); 7 | 8 | String s1 = new String("Strings are arrays of characters"); 9 | String s2 = new String("Strings are arrays of characters"); 10 | 11 | printer.println("string1: " + s1.replace("characters", "char")); 12 | printer.println("string2: " + s2); 13 | } 14 | } -------------------------------------------------------------------------------- /Chapter08/8.2/Strings_Start.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | public class Strings { 4 | 5 | public static void main(String[] args) { 6 | String s1 = new String("Strings are arrays of characters"); 7 | String s2 = new String("Strings are arrays of characters"); 8 | 9 | System.out.println("string1: " + s1.replace("characters", "char")); 10 | System.out.println("string2: " + s2); 11 | System.out.println(s1 == s2); 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /Chapter08/8.3/Exceptions_End.java: -------------------------------------------------------------------------------- 1 | package exceptions; 2 | 3 | import java.util.*; 4 | 5 | public class Exceptions { 6 | public static void main(String[] args) { 7 | Scanner reader = new Scanner(System.in); 8 | 9 | while(true) { 10 | try{ 11 | System.out.print("Input a number: "); 12 | float input = reader.nextFloat(); 13 | System.out.println("You input the number: " + input); 14 | System.out.println("\r\n"); 15 | } 16 | catch(InputMismatchException e) 17 | { 18 | System.out.println("You passed invalid input. Not a float!"); 19 | e.printStackTrace(System.out); 20 | System.out.println("\r\n"); 21 | } 22 | finally 23 | { 24 | reader.nextLine(); 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Chapter08/8.3/Exceptions_Start.java: -------------------------------------------------------------------------------- 1 | package exceptions; 2 | 3 | import java.util.*; 4 | 5 | public class Exceptions { 6 | public static void main(String[] args) { 7 | Scanner reader = new Scanner(System.in); 8 | 9 | while(true) { 10 | System.out.print("Input a number: "); 11 | float input = reader.nextFloat(); 12 | System.out.println("You input the number: " + input); 13 | System.out.println("\r\n"); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Chapter08/8.4/MyClass.java: -------------------------------------------------------------------------------- 1 | package theobjectclass; 2 | 3 | 4 | public class MyClass { 5 | public String value; 6 | public MyClass(String value) 7 | { 8 | this.value = value; 9 | System.out.println("A MyClass object was created with value:" + value); 10 | } 11 | public void MyMethod() 12 | { 13 | System.out.println("MyMethod was called on a MyClass object with value: " + value); 14 | } 15 | 16 | @Override 17 | public boolean equals(Object obj) 18 | { 19 | if(obj == null) 20 | return false; 21 | 22 | if(!(obj instanceof MyClass)) 23 | return false; 24 | 25 | return value.equals(((MyClass)obj).value); 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /Chapter08/8.4/TheObjectClass.java: -------------------------------------------------------------------------------- 1 | package theobjectclass; 2 | 3 | public class TheObjectClass { 4 | 5 | 6 | public static void main(String[] args) { 7 | MyClass object1 = new MyClass("abcdefg"); 8 | MyClass object2 = new MyClass("abcdefg"); 9 | 10 | object1.MyMethod(); 11 | object2.MyMethod(); 12 | 13 | System.out.println("The objects are the same: " + (object1 == object2)); 14 | System.out.println("The objects are the same: " + object1.equals(object2)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Chapter08/8.5/ThePrimitiveClasses.java: -------------------------------------------------------------------------------- 1 | package the.primitiveclasses; 2 | 3 | public class ThePrimitiveClasses { 4 | 5 | public static void main(String[] args) { 6 | String s = "string"; 7 | 8 | 9 | char c = 'C'; 10 | System.out.println(Character.isLowerCase(c)); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Chapter09/9.1/WritingToFiles_End.java: -------------------------------------------------------------------------------- 1 | package writingtofiles; 2 | 3 | import java.io.*; 4 | 5 | public class WritingToFiles { 6 | public static void main(String[] args) throws IOException { 7 | BufferedWriter out = null; 8 | 9 | try { 10 | out = new BufferedWriter(new FileWriter("out.txt", true)); 11 | 12 | for(long number : FibonacciNumbers()) 13 | { 14 | out.write(String.valueOf(number) + "\r\n"); 15 | //System.out.println(number); 16 | } 17 | } 18 | catch(IOException e) { 19 | System.err.println("File IO Failed."); 20 | } 21 | finally{ 22 | out.close(); 23 | } 24 | } 25 | 26 | private static long[] FibonacciNumbers() 27 | { 28 | long[] fibNumbers = new long[50]; 29 | fibNumbers[0] = 0; 30 | fibNumbers[1] = 1; 31 | for(int i = 2; i < 50; i++) 32 | { 33 | fibNumbers[i] = fibNumbers[i - 1] + fibNumbers[i - 2]; 34 | } 35 | return fibNumbers; 36 | } 37 | } -------------------------------------------------------------------------------- /Chapter09/9.1/WritingToFiles_Start.java: -------------------------------------------------------------------------------- 1 | package writingtofiles; 2 | 3 | public class WritingToFiles { 4 | public static void main(String[] args) throws IOException { 5 | for(long number : FibonacciNumbers()) 6 | { 7 | System.out.println(number); 8 | } 9 | } 10 | 11 | private static long[] FibonacciNumbers() 12 | { 13 | long[] fibNumbers = new long[50]; 14 | fibNumbers[0] = 0; 15 | fibNumbers[1] = 1; 16 | for(int i = 2; i < 50; i++) 17 | { 18 | fibNumbers[i] = fibNumbers[i - 1] + fibNumbers[i - 2]; 19 | } 20 | return fibNumbers; 21 | } 22 | } -------------------------------------------------------------------------------- /Chapter09/9.2/InputAndOutput_End.java: -------------------------------------------------------------------------------- 1 | package inputandoutput; 2 | 3 | import java.io.*; 4 | 5 | public class InputAndOutput { 6 | public static void main(String[] args) throws IOException { 7 | File outFile = new File("OutputFile.txt"); 8 | File inFile = new File("InputFile.txt"); 9 | 10 | FileWriter out = new FileWriter(outFile); 11 | BufferedReader in = new BufferedReader(new FileReader(inFile)); 12 | 13 | //Code Here... 14 | String input = ""; 15 | String newInput; 16 | while((newInput = in.readLine()) != null) 17 | { 18 | input += (newInput + "\r\n"); 19 | } 20 | out.write(input); 21 | 22 | out.close(); 23 | in.close(); 24 | } 25 | } -------------------------------------------------------------------------------- /Chapter09/9.2/InputAndOutput_Start.java: -------------------------------------------------------------------------------- 1 | package inputandoutput; 2 | 3 | import java.io.*; 4 | 5 | public class InputAndOutput { 6 | public static void main(String[] args) throws IOException { 7 | File outFile = new File("OutputFile.txt"); 8 | File inFile = new File("InputFile.txt"); 9 | 10 | FileWriter out = new FileWriter(outFile); 11 | FileReader in = new FileReader(inFile); 12 | 13 | //Code Here... 14 | 15 | out.close(); 16 | in.close(); 17 | } 18 | } -------------------------------------------------------------------------------- /Chapter09/9.3 End/Car.java: -------------------------------------------------------------------------------- 1 | package serialization; 2 | 3 | import java.io.*; 4 | 5 | public class Car implements Serializable { 6 | public String vin; 7 | public String make; 8 | public String model; 9 | public String color; 10 | public int year; 11 | 12 | public Car(String vin, String make, String model, String color, int year) 13 | { 14 | this.vin = vin; 15 | this.make = make; 16 | this.model = model; 17 | this.color = color; 18 | this.year = year; 19 | } 20 | 21 | @Override 22 | public String toString() 23 | { 24 | return String.format("%d %s %s %s, vin:%s", 25 | year, color, make, model, vin); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter09/9.3 End/DeSerialize.java: -------------------------------------------------------------------------------- 1 | package serialization; 2 | 3 | import java.io.*; 4 | 5 | public class DeSerialize { 6 | public static void main(String argv[]) { 7 | Car c = null; 8 | 9 | try { 10 | FileInputStream inFile = new FileInputStream("serialized.dat"); 11 | ObjectInputStream in = new ObjectInputStream(inFile); 12 | c = (Car)in.readObject(); 13 | in.close(); 14 | inFile.close(); 15 | } 16 | catch(IOException e) 17 | { 18 | System.err.println("ERROR"); 19 | } 20 | catch(ClassNotFoundException e) 21 | { 22 | System.err.println("ERROR"); 23 | } 24 | 25 | System.out.println(c.toString()); 26 | } 27 | } -------------------------------------------------------------------------------- /Chapter09/9.3 End/Serialize.java: -------------------------------------------------------------------------------- 1 | package serialization; 2 | 3 | import java.io.*; 4 | 5 | public class Serialize { 6 | public static void main(String argv[]) { 7 | Car c = new Car("FDAJFD54254", "Nisan", "Altima", "Green", 2000); 8 | 9 | try { 10 | FileOutputStream outFile = new FileOutputStream("serialized.dat"); 11 | ObjectOutputStream out = new ObjectOutputStream(outFile); 12 | out.writeObject(c); 13 | out.close(); 14 | outFile.close(); 15 | } 16 | catch(IOException e) 17 | { 18 | System.err.println("ERROR"); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Chapter09/9.3 Start/Car.java: -------------------------------------------------------------------------------- 1 | package serialization; 2 | 3 | public class Car { 4 | public String vin; 5 | public String make; 6 | public String model; 7 | public String color; 8 | public int year; 9 | 10 | public Car(String vin, String make, String model, String color, int year) 11 | { 12 | this.vin = vin; 13 | this.make = make; 14 | this.model = model; 15 | this.color = color; 16 | this.year = year; 17 | } 18 | 19 | @Override 20 | public String toString() 21 | { 22 | return String.format("%d %s %s %s, vin:%s", 23 | year, color, make, model, vin); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter10/GUI.java: -------------------------------------------------------------------------------- 1 | package gui; 2 | import javax.swing.*; 3 | import java.awt.*; 4 | public class GUI { 5 | 6 | 7 | public static void main(String[] args) { 8 | Runnable GUITask = new Runnable(){ 9 | @Override 10 | public void run(){ 11 | MakeGUI(); 12 | } 13 | }; 14 | SwingUtilities.invokeLater(GUITask); 15 | } 16 | private static void MakeGUI() 17 | { 18 | JFrame frame = new JFrame("Hello World GUI"); 19 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 20 | frame.setPreferredSize(new Dimension(400, 400)); 21 | JLabel label = new JLabel("Hi. I am a GUI."); 22 | frame.getContentPane().add(label); 23 | frame.pack(); 24 | frame.setVisible(true); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Chapter10/MyGUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package gui; 7 | 8 | import javax.swing.JOptionPane; 9 | 10 | /** 11 | * 12 | * @author nidhishas 13 | */ 14 | public class MyGUI extends javax.swing.JFrame { 15 | 16 | /** 17 | * Creates new form MyGUI1 18 | */ 19 | public MyGUI() { 20 | initComponents(); 21 | } 22 | 23 | /** 24 | * This method is called from within the constructor to initialize the form. 25 | * WARNING: Do NOT modify this code. The content of this method is always 26 | * regenerated by the Form Editor. 27 | */ 28 | @SuppressWarnings("unchecked") 29 | // 30 | private void initComponents() { 31 | 32 | jLabel1 = new javax.swing.JLabel(); 33 | jTextField1 = new javax.swing.JTextField(); 34 | jLabel2 = new javax.swing.JLabel(); 35 | jLabel3 = new javax.swing.JLabel(); 36 | jPasswordField1 = new javax.swing.JPasswordField(); 37 | submitButton = new javax.swing.JButton(); 38 | 39 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 40 | 41 | jLabel1.setText("Please enter a username and password."); 42 | 43 | jTextField1.setToolTipText(""); 44 | jTextField1.addActionListener(new java.awt.event.ActionListener() { 45 | public void actionPerformed(java.awt.event.ActionEvent evt) { 46 | jTextField1ActionPerformed(evt); 47 | } 48 | }); 49 | 50 | jLabel2.setText("Username:"); 51 | 52 | jLabel3.setText("Password:"); 53 | 54 | jPasswordField1.addActionListener(new java.awt.event.ActionListener() { 55 | public void actionPerformed(java.awt.event.ActionEvent evt) { 56 | jPasswordField1ActionPerformed(evt); 57 | } 58 | }); 59 | 60 | submitButton.setText("Submit"); 61 | submitButton.addActionListener(new java.awt.event.ActionListener() { 62 | public void actionPerformed(java.awt.event.ActionEvent evt) { 63 | submitButtonActionPerformed(evt); 64 | } 65 | }); 66 | 67 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 68 | getContentPane().setLayout(layout); 69 | layout.setHorizontalGroup( 70 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 71 | .addGroup(layout.createSequentialGroup() 72 | .addContainerGap() 73 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 74 | .addComponent(jLabel1) 75 | .addGroup(layout.createSequentialGroup() 76 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 77 | .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE) 78 | .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 79 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 80 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 81 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) 82 | .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) 83 | .addComponent(submitButton)))) 84 | .addContainerGap(65, Short.MAX_VALUE)) 85 | ); 86 | layout.setVerticalGroup( 87 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 88 | .addGroup(layout.createSequentialGroup() 89 | .addGap(22, 22, 22) 90 | .addComponent(jLabel1) 91 | .addGap(2, 2, 2) 92 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 93 | .addComponent(jLabel2) 94 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 95 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 96 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 97 | .addComponent(jLabel3) 98 | .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 99 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 100 | .addComponent(submitButton) 101 | .addContainerGap(91, Short.MAX_VALUE)) 102 | ); 103 | 104 | pack(); 105 | }// 106 | 107 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { 108 | // TODO add your handling code here: 109 | } 110 | 111 | private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) { 112 | // TODO add your handling code here: 113 | } 114 | 115 | private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) { 116 | String password = new String(jPasswordField1.getPassword()); 117 | if (jTextField1.getText().equals("username") 118 | && password.equals("java")) 119 | { 120 | JOptionPane.showMessageDialog(this, "Login Good!"); 121 | } 122 | } 123 | 124 | /** 125 | * @param args the command line arguments 126 | */ 127 | public static void main(String args[]) { 128 | /* Set the Nimbus look and feel */ 129 | // 130 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 131 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 132 | */ 133 | try { 134 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 135 | if ("Nimbus".equals(info.getName())) { 136 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 137 | break; 138 | } 139 | } 140 | } catch (ClassNotFoundException ex) { 141 | java.util.logging.Logger.getLogger(MyGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 142 | } catch (InstantiationException ex) { 143 | java.util.logging.Logger.getLogger(MyGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 144 | } catch (IllegalAccessException ex) { 145 | java.util.logging.Logger.getLogger(MyGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 146 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 147 | java.util.logging.Logger.getLogger(MyGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 148 | } 149 | // 150 | // 151 | 152 | /* Create and display the form */ 153 | java.awt.EventQueue.invokeLater(new Runnable() { 154 | public void run() { 155 | new MyGUI().setVisible(true); 156 | } 157 | }); 158 | } 159 | 160 | // Variables declaration - do not modify 161 | private javax.swing.JLabel jLabel1; 162 | private javax.swing.JLabel jLabel2; 163 | private javax.swing.JLabel jLabel3; 164 | private javax.swing.JPasswordField jPasswordField1; 165 | private javax.swing.JTextField jTextField1; 166 | private javax.swing.JButton submitButton; 167 | // End of variables declaration 168 | } 169 | -------------------------------------------------------------------------------- /Chapter11/11.1/LoadingAnXMLFile_End.java: -------------------------------------------------------------------------------- 1 | package loadinganxmlfile; 2 | 3 | import java.io.*; 4 | import javax.xml.parsers.*; 5 | import javax.xml.transform.*; 6 | import javax.xml.transform.dom.*; 7 | import javax.xml.transform.stream.*; 8 | import org.w3c.dom.*; 9 | import org.xml.sax.*; 10 | 11 | public class LoadingAnXMLFile { 12 | public static void main(String[] args) { 13 | Document dom; 14 | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 15 | 16 | try { 17 | // Write code that can throw errors here... 18 | DocumentBuilder builder = factory.newDocumentBuilder(); 19 | dom = builder.parse("cars.xml"); 20 | 21 | PrintXmlDocument(dom); 22 | } 23 | catch (ParserConfigurationException pce) { 24 | System.out.println(pce.getMessage()); 25 | } 26 | catch (SAXException se) { 27 | System.out.println(se.getMessage()); 28 | } 29 | catch (IOException ioe) { 30 | System.err.println(ioe.getMessage()); 31 | } 32 | } 33 | 34 | private static void PrintXmlDocument(Document xml) 35 | { 36 | try{ 37 | Transformer transformer = TransformerFactory.newInstance().newTransformer(); 38 | StreamResult result = new StreamResult(new StringWriter()); 39 | DOMSource source = new DOMSource(xml); 40 | transformer.transform(source, result); 41 | System.out.println(result.getWriter().toString()); 42 | } 43 | catch(TransformerConfigurationException e) 44 | { 45 | System.err.println("XML Printing Failed"); 46 | } 47 | catch(TransformerException e) 48 | { 49 | System.err.println("XML Printing Failed"); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Chapter11/11.1/LoadingAnXMLFile_Start.java: -------------------------------------------------------------------------------- 1 | package loadinganxmlfile; 2 | 3 | import java.io.*; 4 | import javax.xml.parsers.*; 5 | import javax.xml.transform.*; 6 | import javax.xml.transform.dom.*; 7 | import javax.xml.transform.stream.*; 8 | import org.w3c.dom.*; 9 | import org.xml.sax.*; 10 | 11 | public class LoadingAnXMLFile { 12 | public static void main(String[] args) { 13 | 14 | try { 15 | // Write code that can throw errors here... 16 | } 17 | catch (ParserConfigurationException pce) { 18 | System.out.println(pce.getMessage()); 19 | } 20 | catch (SAXException se) { 21 | System.out.println(se.getMessage()); 22 | } 23 | catch (IOException ioe) { 24 | System.err.println(ioe.getMessage()); 25 | } 26 | } 27 | 28 | private static void PrintXmlDocument(Document xml) 29 | { 30 | try{ 31 | Transformer transformer = TransformerFactory.newInstance().newTransformer(); 32 | StreamResult result = new StreamResult(new StringWriter()); 33 | DOMSource source = new DOMSource(xml); 34 | transformer.transform(source, result); 35 | System.out.println(result.getWriter().toString()); 36 | } 37 | catch(TransformerConfigurationException e) 38 | { 39 | System.err.println("XML Printing Failed"); 40 | } 41 | catch(TransformerException e) 42 | { 43 | System.err.println("XML Printing Failed"); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Chapter11/11.1/cars.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ford 6 | Fusion 7 | 2014 8 | Blue 9 | 10 | 11 | Toyota 12 | Tacoma 13 | 2013 14 | Green 15 | 16 | 17 | Dodge 18 | Charger 19 | 2013 20 | Red 21 | 22 | 23 | 24 | 25 | Nissan 26 | Altima 27 | 2000 28 | Green 29 | 30 | 31 | Dodge 32 | Challenger 33 | 2013 34 | Red 35 | 36 | 37 | -------------------------------------------------------------------------------- /Chapter11/11.2/Car.java: -------------------------------------------------------------------------------- 1 | 2 | package readingxml; 3 | 4 | 5 | public class Car { 6 | public String vin; 7 | public String make; 8 | public String model; 9 | public int year; 10 | public String color; 11 | public Car() 12 | { 13 | 14 | } 15 | @Override 16 | public String toString() 17 | { 18 | return String.format("%d %s %s %s, vin:%s", year, 19 | color, make,model, vin); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Chapter11/11.2/ReadingXML_End.java: -------------------------------------------------------------------------------- 1 | package readingxml; 2 | 3 | import java.io.IOException; 4 | import javax.xml.parsers.*; 5 | import org.w3c.dom.Document; 6 | import org.w3c.dom.Element; 7 | import org.w3c.dom.NodeList; 8 | import org.xml.sax.SAXException; 9 | 10 | public class ReadingXML { 11 | public static void main(String[] args) { 12 | 13 | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 14 | try { 15 | DocumentBuilder docBuilder = factory.newDocumentBuilder(); 16 | Document dom = docBuilder.parse("cars.xml"); 17 | 18 | // Now, print out all of Jane's cars... 19 | Element doc = dom.getDocumentElement(); 20 | NodeList ownersList = doc.getElementsByTagName("owner"); 21 | 22 | for(int i = 0; i < ownersList.getLength(); i++) 23 | { 24 | Element owner = (Element)ownersList.item(i); 25 | if(owner.getAttribute("name").equals("Jane")) 26 | { 27 | NodeList carsList = owner.getElementsByTagName("car"); 28 | PrintCars(carsList); 29 | } 30 | } 31 | } 32 | catch (ParserConfigurationException pce) { 33 | System.out.println(pce.getMessage()); 34 | } 35 | catch (SAXException se) { 36 | System.out.println(se.getMessage()); 37 | } 38 | catch (IOException ioe) { 39 | System.err.println(ioe.getMessage()); 40 | } 41 | } 42 | 43 | public static void PrintCars(NodeList cars) 44 | { 45 | for(int i = 0; i < cars.getLength(); i++) 46 | { 47 | Element carNode = (Element)cars.item(i); 48 | Car carObj = new Car(); 49 | carObj.color = carNode.getElementsByTagName("color").item(0).getTextContent(); 50 | carObj.make = carNode.getElementsByTagName("make").item(0).getTextContent(); 51 | carObj.model = carNode.getElementsByTagName("model").item(0).getTextContent(); 52 | carObj.year = Integer.parseInt(carNode.getElementsByTagName("year").item(0).getTextContent()); 53 | carObj.vin = carNode.getAttribute("vin"); 54 | System.out.println(carObj.toString()); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Chapter11/11.2/ReadingXML_Start.java: -------------------------------------------------------------------------------- 1 | package readingxml; 2 | 3 | import java.io.IOException; 4 | import javax.xml.parsers.*; 5 | import org.w3c.dom.Document; 6 | import org.w3c.dom.Element; 7 | import org.w3c.dom.NodeList; 8 | import org.xml.sax.SAXException; 9 | 10 | public class ReadingXML { 11 | public static void main(String[] args) { 12 | 13 | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 14 | try { 15 | DocumentBuilder docBuilder = factory.newDocumentBuilder(); 16 | Document dom = docBuilder.parse("cars.xml"); 17 | 18 | // Now, print out all of Jane's cars... 19 | 20 | } 21 | catch (ParserConfigurationException pce) { 22 | System.out.println(pce.getMessage()); 23 | } 24 | catch (SAXException se) { 25 | System.out.println(se.getMessage()); 26 | } 27 | catch (IOException ioe) { 28 | System.err.println(ioe.getMessage()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Chapter11/11.2/cars.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ford 6 | Fusion 7 | 2014 8 | Blue 9 | 10 | 11 | Toyota 12 | Tacoma 13 | 2013 14 | Green 15 | 16 | 17 | Dodge 18 | Charger 19 | 2013 20 | Red 21 | 22 | 23 | 24 | 25 | Nissan 26 | Altima 27 | 2000 28 | Green 29 | 30 | 31 | Dodge 32 | Challenger 33 | 2013 34 | Red 35 | 36 | 37 | -------------------------------------------------------------------------------- /Chapter11/11.3/WritingXML_End.java: -------------------------------------------------------------------------------- 1 | package writingxml; 2 | 3 | import java.io.*; 4 | import javax.xml.parsers.*; 5 | import javax.xml.transform.*; 6 | import javax.xml.transform.dom.*; 7 | import javax.xml.transform.stream.*; 8 | import org.w3c.dom.*; 9 | import org.xml.sax.*; 10 | 11 | public class WritingXML { 12 | public static void main(String[] args) { 13 | File xmlFile = new File("cars.xml"); 14 | Document dom = LoadXMLDocument(xmlFile); 15 | 16 | NodeList owners = dom.getElementsByTagName("owner"); 17 | for(int i = 0; i < owners.getLength(); i++) 18 | { 19 | Element owner = (Element)owners.item(i); 20 | owner.setAttribute("name", "Mike"); 21 | } 22 | 23 | WriteXMLDocument(dom, xmlFile); 24 | } 25 | 26 | private static void WriteXMLDocument(Document doc, File destination) 27 | { 28 | try{ 29 | // Write doc to destination file here... 30 | TransformerFactory tf = TransformerFactory.newInstance(); 31 | Transformer transformer = tf.newTransformer(); 32 | StreamResult result = new StreamResult(destination); 33 | DOMSource source = new DOMSource(doc); 34 | 35 | transformer.transform(source, result); 36 | } 37 | catch(TransformerConfigurationException e) 38 | { 39 | System.err.println("XML writing failed."); 40 | } 41 | catch(TransformerException e) 42 | { 43 | System.err.println("XML writing failed."); 44 | } 45 | } 46 | 47 | private static Document LoadXMLDocument(File source) 48 | { 49 | Document dom = null; 50 | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 51 | 52 | try { 53 | DocumentBuilder builder = factory.newDocumentBuilder(); 54 | dom = builder.parse(source); 55 | } 56 | catch (ParserConfigurationException e) { 57 | System.err.println("XML loading failed."); 58 | } 59 | catch (SAXException e) { 60 | System.err.println("XML loading failed."); 61 | } 62 | catch (IOException e) { 63 | System.err.println("XML loading failed."); 64 | } 65 | 66 | return dom; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Chapter11/11.3/WritingXML_Start.java: -------------------------------------------------------------------------------- 1 | package writingxml; 2 | 3 | import java.io.*; 4 | import javax.xml.parsers.*; 5 | import javax.xml.transform.*; 6 | import javax.xml.transform.dom.*; 7 | import javax.xml.transform.stream.*; 8 | import org.w3c.dom.*; 9 | import org.xml.sax.*; 10 | 11 | public class WritingXML { 12 | public static void main(String[] args) { 13 | File xmlFile = new File("cars.xml"); 14 | Document dom = LoadXMLDocument(xmlFile); 15 | WriteXMLDocument(dom, xmlFile); 16 | } 17 | 18 | private static void WriteXMLDocument(Document doc, File destination) 19 | { 20 | try{ 21 | // Write doc to destination file here... 22 | } 23 | catch(TransformerConfigurationException e) 24 | { 25 | System.err.println("XML writing failed."); 26 | } 27 | catch(TransformerException e) 28 | { 29 | System.err.println("XML writing failed."); 30 | } 31 | } 32 | 33 | private static Document LoadXMLDocument(File source) 34 | { 35 | Document dom = null; 36 | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 37 | 38 | try { 39 | DocumentBuilder builder = factory.newDocumentBuilder(); 40 | dom = builder.parse(source); 41 | } 42 | catch (ParserConfigurationException e) { 43 | System.err.println("XML loading failed."); 44 | } 45 | catch (SAXException e) { 46 | System.err.println("XML loading failed."); 47 | } 48 | catch (IOException e) { 49 | System.err.println("XML loading failed."); 50 | } 51 | 52 | return dom; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Chapter11/11.3/cars.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ford 6 | Fusion 7 | 2014 8 | Blue 9 | 10 | 11 | Toyota 12 | Tacoma 13 | 2013 14 | Green 15 | 16 | 17 | Dodge 18 | Charger 19 | 2013 20 | Red 21 | 22 | 23 | 24 | 25 | Nissan 26 | Altima 27 | 2000 28 | Green 29 | 30 | 31 | Dodge 32 | Challenger 33 | 2013 34 | Red 35 | 36 | 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 02.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 02.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 03.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 03.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 04.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 04.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 05.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 05.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 06.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 06.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 07.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 07.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 08.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 08.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 09.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 09.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 10.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab 11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab 11.pdf -------------------------------------------------------------------------------- /Labs/Java Programming for Beginner - Lab01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Labs/Java Programming for Beginner - Lab01.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # Java Programming for Beginners 5 | This is the code repository for [Java Programming for Beginners](https://www.packtpub.com/application-development/java-programming-beginners?utm_source=github&utm_medium=repository&utm_campaign=9781788296298), published by [Packt](https://www.packtpub.com/?utm_source=github). It contains all the supporting project files necessary to work through the book from start to finish. 6 | ## About the Book 7 | Java is an object-oriented programming language, and is one of the most widely accepted languages because of its design and programming features, particularly in its promise that you can write a program once and run it anywhere. 8 | 9 | Java Programming for Beginners is an excellent introduction to the world of Java programming, taking you through the basics of Java syntax and the complexities of object-oriented programming. You'll gain a full understanding of Java SE programming and will be able to write Java programs with graphical user interfaces that run on PC, Mac, or Linux machines. This book is full of informative and entertaining content, challenging exercises, and dozens of code examples you can run and learn from. 10 | 11 | By reading this book, you’ll move from understanding the data types in Java, through loops and conditionals, and on to functions, classes, and file handling. The book finishes with a look at GUI development and training on how to work with XML. The book takes an efficient route through the Java landscape, covering all of the core topics that a Java developer needs. Whether you’re an absolute beginner to programming, or a seasoned programmer approaching an object-oriented language for the first time, Java Programming for Beginners delivers the focused training you need to become a Java developer. 12 | 13 | ## Instructions and Navigation 14 | All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02. 15 | 16 | 17 | 18 | The code will look like the following: 19 | ``` 20 | public class HelloWorld { 21 | public static void main(String[] args) { 22 | System.out.println("Hello World!"); 23 | } 24 | } 25 | ``` 26 | 27 | 28 | 29 | ## Related Products 30 | * [Learning Modular Java Programming](https://www.packtpub.com/application-development/learning-modular-java-programming?utm_source=github&utm_medium=repository&utm_campaign=9781785888823) 31 | 32 | * [Reactive Programming With Java 9](https://www.packtpub.com/application-development/reactive-programming-java-9?utm_source=github&utm_medium=repository&utm_campaign=9781787124233) 33 | 34 | * [Modular Programming in Java 9](https://www.packtpub.com/application-development/modular-programming-java-9?utm_source=github&utm_medium=repository&utm_campaign=9781787126909) 35 | 36 | 37 | -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 01 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 01 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 02 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 02 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 03 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 03 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 04 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 04 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 05 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 05 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 06 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 06 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 07 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 07 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 08 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 08 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 09 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 09 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 10 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 10 Solutions.pdf -------------------------------------------------------------------------------- /Solutions/Java Programming for Beginner - Lab 11 Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Programming-for-Beginners/964cccfcf0994c7bc274051346fc53d67766d14c/Solutions/Java Programming for Beginner - Lab 11 Solutions.pdf --------------------------------------------------------------------------------