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

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 

Último (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 

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.