SlideShare una empresa de Scribd logo
1 de 103
JAVA ESSENTIALS BY RICH HELTON (SUN CERTIFIED (SC) JAVA PROGRAMMER, SC JAVA DEVELOPER, SC ENTERPRISE ARCHITECT) January 2009
Java, the beginning … ,[object Object],[object Object],[object Object],[object Object],[object Object]
Java, the beginning … ,[object Object],[object Object],[object Object],[object Object]
Java, the history … Version Year New Features 1.0 1996 1.1 1997 Inner classes 1.2 1998 Swing, Collections 1.3 2000 Performance enhancements 1.4 2002 Assertions, XML 5 2004 Generic classes, enhanced for loop, auto-boxing, enumerations 6 2006 Library improvements
My First Java Program… public class MyFirstJavaProgram { // Start the program public static void main(String[] args){ if(args.length >0){ // If argument print name String myName = (String) args[0]; System.out.println("Hello " +myName); }else{ // Else print System.out.println("Hello there"); } } }
Find it your java program… ,[object Object]
Find the compiler… ,[object Object],[object Object]
Compile… ,[object Object]
Run the program… ,[object Object]
LET’S BREAK DOWN THE PROGRAM
Components of this application… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Comments ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reserved Words ,[object Object],[object Object],[object Object],[object Object],[object Object]
Sample Reserved Words public class  MyFirstJavaProgram { // Start the program public static void  main(String[] args){ if (args.length >0){ // If argument print name String myName = (String) args[0]; System.out.println("Hello " +myName); } else { // Else print System.out.println("Hello there"); } } }
Modifiers, or Access Modifiers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Public,  Protected and Private ,[object Object],[object Object],[object Object]
Sample Modifiers public class  MyFirstJavaProgram { // Start the program public static  void main(String[] args){ if(args.length >0){ // If argument print name String myName = (String) args[0]; System.out.println("Hello " +myName); }else{ // Else print System.out.println("Hello there"); } } }
Statements ,[object Object],[object Object],[object Object],[object Object],[object Object]
Blocks ,[object Object],[object Object]
Sample Block
Main method ,[object Object],[object Object],[object Object],[object Object]
Main method ,[object Object],[object Object],[object Object],[object Object]
What is a class? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A BRIEF INTRODUCTION INTO OBJECT ORIENTED PROGRAMMING (OOP)
A brief introduction to OOP ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Polymorphism ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Polymorphism ,[object Object],[object Object]
Polymorphism, continuing… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object]
Inheritance ,[object Object],[object Object],[object Object],[object Object]
Inheritance, continuing… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Encapsulation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Putting it all together ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2 nd  Java Sample Program with an object ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Some new terms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2 nd  Java Program object creation ,[object Object],[object Object],[object Object],[object Object]
2 nd  Java Program object creation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What happened ,[object Object],[object Object],[object Object],[object Object]
Extending functionality ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Extending functionality ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Extending functionality ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SUPER ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reflection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reflection (finding my fields/methods) class WhoAmI{ String test1 =&quot;I think&quot;; String test2 = &quot;Therefore I am&quot;; void CanYouSeeMe(){} void WhoAreYou(){ System. out.println(&quot;WhoAmI:&quot; +this.getClass().getName()); Method [] methods = this.getClass().getDeclaredMethods(); Field [] fields = this.getClass().getDeclaredFields(); for(int i =0; i < methods.length;i++)   System. out.println(&quot;Method:&quot; +methods[i].getName()); for(int i =0; i < fields.length;i++)   System. out.println(&quot;Field:&quot; +fields[i].getName()); }
Reflection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Abstract (Must Do) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Final (Don’t Change) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Import ,[object Object],[object Object],[object Object],[object Object]
JAR ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JAR Example
Java Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Packages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
INPUT/OUTPUT (I/O)
Strings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
StringBuffer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Strings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
StringTokenizer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Files ,[object Object],[object Object],[object Object],[object Object],[object Object]
Create a File import java.io.*; public class CreateAFile { public static void main(String[] argv) throws IOException { // Ensure that a filename (or something) was given in  argv[0] if (argv.length == 0) { System.err.println(&quot;Usage: CreateAFile filename&quot;); System.exit(1); } // If  arg is filled then create that file for (int i = 0; i< argv.length; i++) { new File(argv[i]).createNewFile( ); } } }
List a Directory with “ls” ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Open a File import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class FileReader { public static void main(String[] args) { try{ Scanner text = new Scanner( new File( &quot;Test.txt&quot; ) ); }catch(FileNotFoundException ex){ System. out.println(&quot;Error: &quot; +ex.getMessage()); } } }
Scanner and File ,[object Object],[object Object],[object Object],[object Object]
Regular Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Regular Expressions resources http://www.regular-expressions.info/java.html http://java.sun.com/docs/books/tutorial/essential/regex/ http://www.sitepoint.com/article/java-regex-api-explained/
Sockets ,[object Object],[object Object],[object Object],[object Object]
Client Socket ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Server Socket ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Httpd (Http Server) continue ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Httpd continue ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Browsing Httpd ,[object Object]
URL (Uniform Resource Locators) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Browsing becomes simplified ,[object Object],[object Object],[object Object]
Browsing becomes simplified public static void main(String[] args) { org.eclipse.swt.widgets.Display display = org.eclipse.swt.widgets.Display .getDefault(); SimpleSWTBrowser thisClass = new SimpleSWTBrowser(); thisClass.createSShell(); thisClass.sShell.open(); while (!thisClass.sShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } //The URL is called in the createSShell code
Browsing becomes simplified
NIO (New I/O) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Extensible Markup Language (XML) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XML and Serialization ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XML Bean ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Now it is an XML object <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>  <java version=&quot;1.6.0_07&quot; class=&quot;java.beans.XMLDecoder&quot;>  <object class=&quot;MyData&quot;>  <void property=&quot;name&quot;>  <string>testXML</string>  </void>  </object>  </java>
SAX ,[object Object],[object Object],[object Object]
SAX import java.io.IOException; import org.xml.sax.*; public class SAXParser{ public static void main(String[] args) throws Exception { new SAXParser(args); } public SAXParser(String[] args) throws SAXException, IOException { XMLReader parser = XMLReaderFactory. createXMLReader(); parser.setContentHandler(new MyDataHandler()); parser.parse(args.length == 1 ? args[0] : &quot;Test.xml&quot;); }
SAX (handler) // Inner class provides DocumentHandler class MyDataHandler extends DefaultHandler { boolean name = false; // Set to true when string tag is found public void startElement(String nsURI, String localName, String rawName, Attributes attributes) throws SAXException { if (rawName.equalsIgnoreCase(&quot;string&quot;)) name = true; } public void characters(char[] ch, int start, int length) { if (name) {  //Will print all name strings found System. out.println(&quot;MyData name:  &quot; +  new String(ch, start, length)); name = false; }  } } }
DOM ,[object Object],[object Object],[object Object],[object Object],[object Object]
ARRAYS, LOOPS AND COLLECTIONS
Arrays, Loops and Collections ,[object Object],[object Object],[object Object],[object Object]
Arrays ,[object Object],[object Object]
Arrays, the code public class ArrayProgram { public static void main(String[] args){ String [] strArray = new String[3]; strArray[0] = &quot;One&quot;; //Java starts at 0 strArray[1] = &quot;Two&quot;; strArray[2] = &quot;Three&quot;; int [] [] intArray = new int[2][]; // 2 rows intArray[0] = new int[3];  // three columns for row 0 intArray[1] = new int[4];  // four columns for row 1 int data = 1; for(int i1 = 0; i1 < intArray.length; i1++){   for(int i2 = 0; i2 < intArray[i1].length; i2++){ intArray[i1][i2] = data++;   } }
Arrays, the code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Conditionals ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
if, else if, else ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
&& and || operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
switch ,[object Object],[object Object],[object Object],[object Object]
Switch demo class SwitchDemo { public static void main(String[] args) { int month = 8; switch (month) { case 1:  System.out.println(&quot;January&quot;); break; case 2:  System.out.println(&quot;February&quot;); break; case 3:  System.out.println(&quot;March&quot;); break; case 4:  System.out.println(&quot;April&quot;); break; case 5:  System.out.println(&quot;May&quot;); break; case 6:  System.out.println(&quot;June&quot;); break; case 7:  System.out.println(&quot;July&quot;); break; case 8:  System.out.println(&quot;August&quot;); break; case 9:  System.out.println(&quot;September&quot;); break; case 10: System.out.println(&quot;October&quot;); break; case 11: System.out.println(&quot;November&quot;); break; case 12: System.out.println(&quot;December&quot;); break; default: System.out.println(&quot;Invalid month.&quot;);break; }}}
The “for” loop ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The “for each” loop ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The “while” loop ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Let’s “break” and “continue ,[object Object],[object Object],[object Object],[object Object]
“ break” and “continue example public static void main(String[] args) { boolean bFirstLoop = true, boolean bBreakMe = true, bContinue = true; while(bFirstLoop){ System.out.println(&quot;While Loop&quot;); if(bBreakMe) break; // Prints only one “While Loop” } for(int i = 0; i < 3;i++){ if(bContinue){ bContinue = false; continue; } System.out.println(&quot;For Loop&quot;); //Prints twice, skips first time } }
Benefits of Collections ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Linked List ,[object Object],[object Object],[object Object],[object Object]
Linked List, some code import java.util.LinkedList; public class ListProgram {   public static void main(String[] args) { LinkedList < String>  strList = new LinkedList <String>(); strList.add(&quot;One&quot;); strList.add(&quot;Two&quot;); strList.add(&quot;Three&quot;); System. out.print(&quot;Output -> The Linked List vaues =&quot;); for(int i1 = 0; i1 < strList.size(); i1++) System. out.printf(&quot;%s &quot;, strList.get(i1));   } } Output -> The Linked List vaues =One Two Three
Labs ,[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

La actualidad más candente

JSR 168 Portal - Overview
JSR 168 Portal - OverviewJSR 168 Portal - Overview
JSR 168 Portal - OverviewVinay Kumar
 
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1Rich Helton
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python MeetupAreski Belaid
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran TochAdil Jafri
 
IPaste SDK v.1.0
IPaste SDK v.1.0IPaste SDK v.1.0
IPaste SDK v.1.0xrebyc
 
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseGet ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseJeanne Boyarsky
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programmingKuntal Bhowmick
 
Great cup of java
Great  cup of javaGreat  cup of java
Great cup of javaCIB Egypt
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersKrishnaov
 

La actualidad más candente (18)

JSR 168 Portal - Overview
JSR 168 Portal - OverviewJSR 168 Portal - Overview
JSR 168 Portal - Overview
 
Java essential notes
Java essential notesJava essential notes
Java essential notes
 
Spring aop
Spring aopSpring aop
Spring aop
 
Flask Basics
Flask BasicsFlask Basics
Flask Basics
 
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
B.Sc. III(VI Sem) Advance Java Unit2: Appet
B.Sc. III(VI Sem) Advance Java Unit2: AppetB.Sc. III(VI Sem) Advance Java Unit2: Appet
B.Sc. III(VI Sem) Advance Java Unit2: Appet
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
IPaste SDK v.1.0
IPaste SDK v.1.0IPaste SDK v.1.0
IPaste SDK v.1.0
 
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseGet ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
 
Java Programming - 01 intro to java
Java Programming - 01 intro to javaJava Programming - 01 intro to java
Java Programming - 01 intro to java
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
Java notes
Java notesJava notes
Java notes
 
Great cup of java
Great  cup of javaGreat  cup of java
Great cup of java
 
Hibernate Advance Interview Questions
Hibernate Advance Interview QuestionsHibernate Advance Interview Questions
Hibernate Advance Interview Questions
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Corejava ratan
Corejava ratanCorejava ratan
Corejava ratan
 

Similar a Java essentials guide covers language history and basics

Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objectsvmadan89
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using ReflectionGanesh Samarthyam
 
Unit2 java
Unit2 javaUnit2 java
Unit2 javamrecedu
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Ayes Chinmay
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Mohamed Essam
 
Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
Introduction
IntroductionIntroduction
Introductionrichsoden
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...AnkurSingh340457
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questionsGradeup
 

Similar a Java essentials guide covers language history and basics (20)

Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
Java_presesntation.ppt
Java_presesntation.pptJava_presesntation.ppt
Java_presesntation.ppt
 
Basics of java 1
Basics of java 1Basics of java 1
Basics of java 1
 
Javanotes
JavanotesJavanotes
Javanotes
 
01slide
01slide01slide
01slide
 
01slide
01slide01slide
01slide
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Introduction
IntroductionIntroduction
Introduction
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
Java notes
Java notesJava notes
Java notes
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
 
Javascript
JavascriptJavascript
Javascript
 
ANDROID FDP PPT
ANDROID FDP PPTANDROID FDP PPT
ANDROID FDP PPT
 
java tr.docx
java tr.docxjava tr.docx
java tr.docx
 

Más de Rich Helton

Mongo db rev001.
Mongo db rev001.Mongo db rev001.
Mongo db rev001.Rich Helton
 
NServicebus WCF Integration 101
NServicebus WCF Integration 101NServicebus WCF Integration 101
NServicebus WCF Integration 101Rich Helton
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101Rich Helton
 
Entity frameworks101
Entity frameworks101Entity frameworks101
Entity frameworks101Rich Helton
 
Tumbleweed intro
Tumbleweed introTumbleweed intro
Tumbleweed introRich Helton
 
Salesforce Intro
Salesforce IntroSalesforce Intro
Salesforce IntroRich Helton
 
First Steps in Android
First Steps in AndroidFirst Steps in Android
First Steps in AndroidRich Helton
 
Python For Droid
Python For DroidPython For Droid
Python For DroidRich Helton
 
Spring Roo Rev005
Spring Roo Rev005Spring Roo Rev005
Spring Roo Rev005Rich Helton
 
Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Rich Helton
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity FrameworksRich Helton
 
Web Application Firewall intro
Web Application Firewall introWeb Application Firewall intro
Web Application Firewall introRich Helton
 
Java Web Security Class
Java Web Security ClassJava Web Security Class
Java Web Security ClassRich Helton
 

Más de Rich Helton (17)

Mongo db rev001.
Mongo db rev001.Mongo db rev001.
Mongo db rev001.
 
NServicebus WCF Integration 101
NServicebus WCF Integration 101NServicebus WCF Integration 101
NServicebus WCF Integration 101
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
 
Entity frameworks101
Entity frameworks101Entity frameworks101
Entity frameworks101
 
Tumbleweed intro
Tumbleweed introTumbleweed intro
Tumbleweed intro
 
Azure rev002
Azure rev002Azure rev002
Azure rev002
 
Salesforce Intro
Salesforce IntroSalesforce Intro
Salesforce Intro
 
First Steps in Android
First Steps in AndroidFirst Steps in Android
First Steps in Android
 
NServiceBus
NServiceBusNServiceBus
NServiceBus
 
Python For Droid
Python For DroidPython For Droid
Python For Droid
 
Spring Roo Rev005
Spring Roo Rev005Spring Roo Rev005
Spring Roo Rev005
 
Python Final
Python FinalPython Final
Python Final
 
Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4
 
Jira Rev002
Jira Rev002Jira Rev002
Jira Rev002
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity Frameworks
 
Web Application Firewall intro
Web Application Firewall introWeb Application Firewall intro
Web Application Firewall intro
 
Java Web Security Class
Java Web Security ClassJava Web Security Class
Java Web Security Class
 

Último

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Último (20)

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Java essentials guide covers language history and basics

  • 1. JAVA ESSENTIALS BY RICH HELTON (SUN CERTIFIED (SC) JAVA PROGRAMMER, SC JAVA DEVELOPER, SC ENTERPRISE ARCHITECT) January 2009
  • 2.
  • 3.
  • 4. Java, the history … Version Year New Features 1.0 1996 1.1 1997 Inner classes 1.2 1998 Swing, Collections 1.3 2000 Performance enhancements 1.4 2002 Assertions, XML 5 2004 Generic classes, enhanced for loop, auto-boxing, enumerations 6 2006 Library improvements
  • 5. My First Java Program… public class MyFirstJavaProgram { // Start the program public static void main(String[] args){ if(args.length >0){ // If argument print name String myName = (String) args[0]; System.out.println(&quot;Hello &quot; +myName); }else{ // Else print System.out.println(&quot;Hello there&quot;); } } }
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. LET’S BREAK DOWN THE PROGRAM
  • 11.
  • 12.
  • 13.
  • 14. Sample Reserved Words public class MyFirstJavaProgram { // Start the program public static void main(String[] args){ if (args.length >0){ // If argument print name String myName = (String) args[0]; System.out.println(&quot;Hello &quot; +myName); } else { // Else print System.out.println(&quot;Hello there&quot;); } } }
  • 15.
  • 16.
  • 17. Sample Modifiers public class MyFirstJavaProgram { // Start the program public static void main(String[] args){ if(args.length >0){ // If argument print name String myName = (String) args[0]; System.out.println(&quot;Hello &quot; +myName); }else{ // Else print System.out.println(&quot;Hello there&quot;); } } }
  • 18.
  • 19.
  • 21.
  • 22.
  • 23.
  • 24. A BRIEF INTRODUCTION INTO OBJECT ORIENTED PROGRAMMING (OOP)
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. Reflection (finding my fields/methods) class WhoAmI{ String test1 =&quot;I think&quot;; String test2 = &quot;Therefore I am&quot;; void CanYouSeeMe(){} void WhoAreYou(){ System. out.println(&quot;WhoAmI:&quot; +this.getClass().getName()); Method [] methods = this.getClass().getDeclaredMethods(); Field [] fields = this.getClass().getDeclaredFields(); for(int i =0; i < methods.length;i++) System. out.println(&quot;Method:&quot; +methods[i].getName()); for(int i =0; i < fields.length;i++) System. out.println(&quot;Field:&quot; +fields[i].getName()); }
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 51.
  • 52.
  • 53.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60. Create a File import java.io.*; public class CreateAFile { public static void main(String[] argv) throws IOException { // Ensure that a filename (or something) was given in argv[0] if (argv.length == 0) { System.err.println(&quot;Usage: CreateAFile filename&quot;); System.exit(1); } // If arg is filled then create that file for (int i = 0; i< argv.length; i++) { new File(argv[i]).createNewFile( ); } } }
  • 61.
  • 62. Open a File import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class FileReader { public static void main(String[] args) { try{ Scanner text = new Scanner( new File( &quot;Test.txt&quot; ) ); }catch(FileNotFoundException ex){ System. out.println(&quot;Error: &quot; +ex.getMessage()); } } }
  • 63.
  • 64.
  • 65. Regular Expressions resources http://www.regular-expressions.info/java.html http://java.sun.com/docs/books/tutorial/essential/regex/ http://www.sitepoint.com/article/java-regex-api-explained/
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74. Browsing becomes simplified public static void main(String[] args) { org.eclipse.swt.widgets.Display display = org.eclipse.swt.widgets.Display .getDefault(); SimpleSWTBrowser thisClass = new SimpleSWTBrowser(); thisClass.createSShell(); thisClass.sShell.open(); while (!thisClass.sShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } //The URL is called in the createSShell code
  • 76.
  • 77.
  • 78.
  • 79.
  • 80. Now it is an XML object <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <java version=&quot;1.6.0_07&quot; class=&quot;java.beans.XMLDecoder&quot;> <object class=&quot;MyData&quot;> <void property=&quot;name&quot;> <string>testXML</string> </void> </object> </java>
  • 81.
  • 82. SAX import java.io.IOException; import org.xml.sax.*; public class SAXParser{ public static void main(String[] args) throws Exception { new SAXParser(args); } public SAXParser(String[] args) throws SAXException, IOException { XMLReader parser = XMLReaderFactory. createXMLReader(); parser.setContentHandler(new MyDataHandler()); parser.parse(args.length == 1 ? args[0] : &quot;Test.xml&quot;); }
  • 83. SAX (handler) // Inner class provides DocumentHandler class MyDataHandler extends DefaultHandler { boolean name = false; // Set to true when string tag is found public void startElement(String nsURI, String localName, String rawName, Attributes attributes) throws SAXException { if (rawName.equalsIgnoreCase(&quot;string&quot;)) name = true; } public void characters(char[] ch, int start, int length) { if (name) { //Will print all name strings found System. out.println(&quot;MyData name: &quot; + new String(ch, start, length)); name = false; } } } }
  • 84.
  • 85. ARRAYS, LOOPS AND COLLECTIONS
  • 86.
  • 87.
  • 88. Arrays, the code public class ArrayProgram { public static void main(String[] args){ String [] strArray = new String[3]; strArray[0] = &quot;One&quot;; //Java starts at 0 strArray[1] = &quot;Two&quot;; strArray[2] = &quot;Three&quot;; int [] [] intArray = new int[2][]; // 2 rows intArray[0] = new int[3]; // three columns for row 0 intArray[1] = new int[4]; // four columns for row 1 int data = 1; for(int i1 = 0; i1 < intArray.length; i1++){ for(int i2 = 0; i2 < intArray[i1].length; i2++){ intArray[i1][i2] = data++; } }
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94. Switch demo class SwitchDemo { public static void main(String[] args) { int month = 8; switch (month) { case 1: System.out.println(&quot;January&quot;); break; case 2: System.out.println(&quot;February&quot;); break; case 3: System.out.println(&quot;March&quot;); break; case 4: System.out.println(&quot;April&quot;); break; case 5: System.out.println(&quot;May&quot;); break; case 6: System.out.println(&quot;June&quot;); break; case 7: System.out.println(&quot;July&quot;); break; case 8: System.out.println(&quot;August&quot;); break; case 9: System.out.println(&quot;September&quot;); break; case 10: System.out.println(&quot;October&quot;); break; case 11: System.out.println(&quot;November&quot;); break; case 12: System.out.println(&quot;December&quot;); break; default: System.out.println(&quot;Invalid month.&quot;);break; }}}
  • 95.
  • 96.
  • 97.
  • 98.
  • 99. “ break” and “continue example public static void main(String[] args) { boolean bFirstLoop = true, boolean bBreakMe = true, bContinue = true; while(bFirstLoop){ System.out.println(&quot;While Loop&quot;); if(bBreakMe) break; // Prints only one “While Loop” } for(int i = 0; i < 3;i++){ if(bContinue){ bContinue = false; continue; } System.out.println(&quot;For Loop&quot;); //Prints twice, skips first time } }
  • 100.
  • 101.
  • 102. Linked List, some code import java.util.LinkedList; public class ListProgram { public static void main(String[] args) { LinkedList < String> strList = new LinkedList <String>(); strList.add(&quot;One&quot;); strList.add(&quot;Two&quot;); strList.add(&quot;Three&quot;); System. out.print(&quot;Output -> The Linked List vaues =&quot;); for(int i1 = 0; i1 < strList.size(); i1++) System. out.printf(&quot;%s &quot;, strList.get(i1)); } } Output -> The Linked List vaues =One Two Three
  • 103.