U Nyein Oo Director/COO(IT) Myanma Computer Co., Ltd IADCS Diploma Course Advanced Java
Subject Content <ul><li>1. Introduction to Java & OOP </li></ul><ul><li>2. Programming in Java </li></ul><ul><li>3. Types-...
Subject Content (cont) <ul><li>8. Object & Classes in Java </li></ul><ul><li>9. Multithreading </li></ul><ul><li>10. Intro...
Application of Java <ul><li>Inline sound that play in real time  whenever </li></ul><ul><li>a user loads a page </li></ul>...
Introduction to Java <ul><li>- Object Oriented Programming  - Developed by Sun Microsystems  - At  USA in 1991   by  James...
Features of Java <ul><li>Simple </li></ul><ul><li>Object-oriented </li></ul><ul><li>Platform-independent </li></ul><ul><li...
Types of Java Programs <ul><li>Applications </li></ul><ul><ul><li>Command Line </li></ul></ul><ul><ul><li>GUI </li></ul></...
Command Line Application //  Sample Java Program   class HelloWorld{ public static void main(String args[])  { System.out....
Compilation code in Java
Traditional way of compilation
Compiling the sample program <ul><li>C:jdkin>javac HelloWorld.java </li></ul><ul><li>C:jdkin>java HelloWorld </li></ul><...
JDK Tools <ul><li>Java Compiler, 'javac'  </li></ul><ul><li>Java Interpreter, 'java'  </li></ul><ul><li>Java Dissembler, '...
Programming in Java   <ul><li>Variables & Reserved Words </li></ul><ul><li>Data types & Operators </li></ul><ul><li>Contro...
Primitive Types <ul><li>byte </li></ul><ul><li>char </li></ul><ul><li>boolean </li></ul><ul><li>short </li></ul><ul><li>in...
Operators <ul><li>Types of operators </li></ul><ul><ul><li>Arithmetic operators </li></ul></ul><ul><ul><li>Bitwise operato...
Arithmetic Operators + Addition - Subtraction * Multiplication / Division % Modulus ++ Increment -- Decrement
Arithmetic Operators (Contd…) += Addition and assignment -= Subtraction and assignment *= Multiplication and assignment /=...
Relational Operators == Equal to  != Not equal to < Less than > Greater than <= Less than or equal to >= Greater than or e...
Logical Operators   <ul><li>&& Logical AND </li></ul><ul><li>|| Logical OR </li></ul><ul><li>! Logical unary NOT </li></ul>
Conditional Operator   <ul><li>Syntax </li></ul><ul><li>expression1 ? expression2 : expression3; </li></ul><ul><li>  expre...
Control Flow <ul><li>Decision-making   </li></ul><ul><ul><li>if-else statement </li></ul></ul><ul><ul><li>switch-case stat...
Array Declarations <ul><li>Three ways for Array Declaration </li></ul><ul><ul><li>datatype identifier [ ];   </li></ul></u...
Methods in Classes <ul><li>A method is defined as the actual implementation of an operation on an object </li></ul><ul><li...
Sample usage of Method class Temp { static int x = 10;  // variable public static void show( ) {  // method System.out.pri...
String Class <ul><li>Constructor methods  </li></ul><ul><ul><li>String str1 = new String();   </li></ul></ul><ul><ul><li>S...
String Class Methods   <ul><li>charAt( ) </li></ul><ul><li>startsWith() </li></ul><ul><li>endsWith( )  </li></ul><ul><li>c...
java.lang.Math Class   <ul><li>abs() </li></ul><ul><li>ceil() </li></ul><ul><li>floor() </li></ul><ul><li>max() </li></ul>...
<ul><li>java.lang </li></ul><ul><li>java.applet </li></ul><ul><li>java.awt  </li></ul><ul><li>java.io </li></ul><ul><li>ja...
<ul><li>// Text string example </li></ul><ul><li>class Test_String </li></ul><ul><li>{ </li></ul><ul><li>public static voi...
<ul><li>/*---Maths Classes---*/ </li></ul><ul><li>public class  math_methods{ </li></ul><ul><li>public static void main(St...
Upcoming SlideShare
Loading in …5
×

Java Intro

6,764 views

Published on

Published in: Technology, News & Politics
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,764
On SlideShare
0
From Embeds
0
Number of Embeds
40
Actions
Shares
0
Downloads
439
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

Java Intro

  1. 1. U Nyein Oo Director/COO(IT) Myanma Computer Co., Ltd IADCS Diploma Course Advanced Java
  2. 2. Subject Content <ul><li>1. Introduction to Java & OOP </li></ul><ul><li>2. Programming in Java </li></ul><ul><li>3. Types- Primitive, Reference and Garbage Collection </li></ul><ul><li>4. Classes and Packages with OO Programming </li></ul><ul><li>5. Exception Handling with Java </li></ul><ul><li>6. Object Cloning and RTTI </li></ul><ul><li>7. Programming I/O within Java </li></ul>
  3. 3. Subject Content (cont) <ul><li>8. Object & Classes in Java </li></ul><ul><li>9. Multithreading </li></ul><ul><li>10. Introduction to GUI </li></ul><ul><li>11. Programming Windows and Events </li></ul><ul><li>12. Client side Java, Applets and JavaBeans </li></ul><ul><li>13. Network Programming with Java </li></ul><ul><li>14. Programming Server-side Java </li></ul>
  4. 4. Application of Java <ul><li>Inline sound that play in real time whenever </li></ul><ul><li>a user loads a page </li></ul><ul><li>Music that plays in the background on a page </li></ul><ul><li>Cartoon Style Animations </li></ul><ul><li>Real time Video </li></ul><ul><li>Multiplayer interactive games </li></ul>
  5. 5. Introduction to Java <ul><li>- Object Oriented Programming - Developed by Sun Microsystems - At USA in 1991 by James Gosling . </li></ul><ul><li>Originally called Oak - Platform Independent Language. </li></ul><ul><li>Internet Programming Language. </li></ul>
  6. 6. Features of Java <ul><li>Simple </li></ul><ul><li>Object-oriented </li></ul><ul><li>Platform-independent </li></ul><ul><li>Robust </li></ul><ul><li>Safe (Secure) </li></ul><ul><li>High Performance </li></ul><ul><li>Multithreaded </li></ul><ul><li>Distributed </li></ul><ul><li>Dynamic </li></ul>
  7. 7. Types of Java Programs <ul><li>Applications </li></ul><ul><ul><li>Command Line </li></ul></ul><ul><ul><li>GUI </li></ul></ul><ul><li>Applets </li></ul><ul><li>Servlets </li></ul><ul><li>Packages </li></ul><ul><li>Database Applications </li></ul>
  8. 8. Command Line Application // Sample Java Program   class HelloWorld{ public static void main(String args[]) { System.out.println(“Helloworld ”); } }
  9. 9. Compilation code in Java
  10. 10. Traditional way of compilation
  11. 11. Compiling the sample program <ul><li>C:jdkin>javac HelloWorld.java </li></ul><ul><li>C:jdkin>java HelloWorld </li></ul><ul><li>Output </li></ul><ul><ul><li>“ Hello World!” </li></ul></ul>
  12. 12. JDK Tools <ul><li>Java Compiler, 'javac' </li></ul><ul><li>Java Interpreter, 'java' </li></ul><ul><li>Java Dissembler, 'javap' </li></ul><ul><li>Documentation tool, 'javadoc' </li></ul><ul><li>Java Debugger, 'jdb‘ </li></ul><ul><li>Applet viewer, 'appletviewer‘ </li></ul>
  13. 13. Programming in Java <ul><li>Variables & Reserved Words </li></ul><ul><li>Data types & Operators </li></ul><ul><li>Control Structure </li></ul><ul><li>Array Handling </li></ul><ul><li>Classes & Methods </li></ul><ul><li>String & Maths Classes </li></ul>
  14. 14. Primitive Types <ul><li>byte </li></ul><ul><li>char </li></ul><ul><li>boolean </li></ul><ul><li>short </li></ul><ul><li>int </li></ul><ul><li>long </li></ul><ul><li>float </li></ul><ul><li>Double </li></ul>Reference Types Java Type <ul><li>long </li></ul><ul><li>float </li></ul><ul><li>Double </li></ul>
  15. 15. Operators <ul><li>Types of operators </li></ul><ul><ul><li>Arithmetic operators </li></ul></ul><ul><ul><li>Bitwise operators </li></ul></ul><ul><ul><li>Relational operators </li></ul></ul><ul><ul><li>Logical operators </li></ul></ul><ul><ul><li>Conditional operator </li></ul></ul><ul><ul><li>Assignment operator </li></ul></ul>
  16. 16. Arithmetic Operators + Addition - Subtraction * Multiplication / Division % Modulus ++ Increment -- Decrement
  17. 17. Arithmetic Operators (Contd…) += Addition and assignment -= Subtraction and assignment *= Multiplication and assignment /= Division and assignment %= Modulus and assignment
  18. 18. Relational Operators == Equal to != Not equal to < Less than > Greater than <= Less than or equal to >= Greater than or equal to
  19. 19. Logical Operators <ul><li>&& Logical AND </li></ul><ul><li>|| Logical OR </li></ul><ul><li>! Logical unary NOT </li></ul>
  20. 20. Conditional Operator <ul><li>Syntax </li></ul><ul><li>expression1 ? expression2 : expression3; </li></ul><ul><li>  expression1 </li></ul><ul><li>Boolean condition that returns a True or False value </li></ul><ul><li>Expression2 </li></ul><ul><li>Value returned if expression1 evaluates to True </li></ul><ul><li>expression3 </li></ul><ul><li>Value returned if exp1 evaluates to False </li></ul>
  21. 21. Control Flow <ul><li>Decision-making </li></ul><ul><ul><li>if-else statement </li></ul></ul><ul><ul><li>switch-case statement </li></ul></ul><ul><li>Loop </li></ul><ul><ul><li>while loop </li></ul></ul><ul><ul><li>do-while loop </li></ul></ul><ul><ul><li>for loop </li></ul></ul>
  22. 22. Array Declarations <ul><li>Three ways for Array Declaration </li></ul><ul><ul><li>datatype identifier [ ]; </li></ul></ul><ul><ul><li>datatype identifier [ ] = new datatype[size]; </li></ul></ul><ul><ul><li>datatype identifier [ ]= {value1,value2,….valueN}; </li></ul></ul>
  23. 23. Methods in Classes <ul><li>A method is defined as the actual implementation of an operation on an object </li></ul><ul><li>Syntax </li></ul><ul><ul><li>access_specifier modifier datatype method_name(parameter_list) </li></ul></ul><ul><ul><li>{ </li></ul></ul><ul><ul><li>//body of method </li></ul></ul><ul><ul><li>} </li></ul></ul>
  24. 24. Sample usage of Method class Temp { static int x = 10; // variable public static void show( ) { // method System.out.println(x); } public static void main(String args[ ]) { Temp t = new Temp( ); // object 1 t.show( ); // method call Temp t1 = new Temp( ); // object 2 t1.x = 20; t1.show(); }}
  25. 25. String Class <ul><li>Constructor methods </li></ul><ul><ul><li>String str1 = new String(); </li></ul></ul><ul><ul><li>String str2 = new String(“Hello World”); </li></ul></ul><ul><ul><li>char ch[ ] = {“A”,”B”,”C”,”D”,”E”}; </li></ul></ul><ul><ul><li>String str3 = new String(ch); </li></ul></ul><ul><ul><li>String str4 = new String(ch,0,2); </li></ul></ul>
  26. 26. String Class Methods <ul><li>charAt( ) </li></ul><ul><li>startsWith() </li></ul><ul><li>endsWith( ) </li></ul><ul><li>copyValueOf( ) </li></ul><ul><li>toCharArray( ) </li></ul><ul><li>indexOf( ) </li></ul><ul><li>toUpperCase( ) </li></ul><ul><li>toLowerCase( ) </li></ul><ul><li>trim( ) </li></ul><ul><li>equals( ) </li></ul>
  27. 27. java.lang.Math Class <ul><li>abs() </li></ul><ul><li>ceil() </li></ul><ul><li>floor() </li></ul><ul><li>max() </li></ul><ul><li>min() </li></ul><ul><li>round() </li></ul><ul><li>random() </li></ul><ul><li>sqrt() </li></ul><ul><li>sin() </li></ul><ul><li>cos() </li></ul><ul><li>tan() </li></ul>
  28. 28. <ul><li>java.lang </li></ul><ul><li>java.applet </li></ul><ul><li>java.awt </li></ul><ul><li>java.io </li></ul><ul><li>java.util </li></ul>Core Java API <ul><li>java.net </li></ul><ul><li>java.awt.event </li></ul><ul><li>java.rmi </li></ul><ul><li>java.security </li></ul><ul><li>java.sql </li></ul>
  29. 29. <ul><li>// Text string example </li></ul><ul><li>class Test_String </li></ul><ul><li>{ </li></ul><ul><li>public static void main(String args[]) </li></ul><ul><li>{ </li></ul><ul><li>String name=&quot; Hello Java Programming &quot;; </li></ul><ul><li>char ch=name.charAt(6); </li></ul><ul><li>boolean flag1=name.startsWith(&quot;Hello&quot;); </li></ul><ul><li>boolean flag2=name.endsWith(&quot;Java&quot;); </li></ul><ul><li>char nname[]={'l','a','n','g','u','a','g','e'}; </li></ul><ul><li>String subname=name.copyValueOf(nname,5,3); </li></ul><ul><li>int ind1=name.indexOf('J'); </li></ul><ul><li>String up=name.toUpperCase(); </li></ul><ul><li>String lo=name.toLowerCase(); </li></ul><ul><li>String name2=name.trim(); </li></ul><ul><li>System.out.println(&quot;charAt &quot; + ch); </li></ul><ul><li>System.out.println(&quot;Startswith java is &quot;+flag1); </li></ul><ul><li>System.out.println(&quot;Endswith java is &quot;+flag2); </li></ul><ul><li>System.out.println(&quot;copy value of &quot;+subname); </li></ul><ul><li>System.out.println(&quot;Index of &quot;+ind1); </li></ul><ul><li>System.out.println(&quot;To upper case &quot;+up); </li></ul><ul><li>System.out.println(&quot;To lower case &quot;+lo); </li></ul><ul><li>System.out.println(&quot;Trimming is &quot;+name2); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  30. 30. <ul><li>/*---Maths Classes---*/ </li></ul><ul><li>public class math_methods{ </li></ul><ul><li>public static void main(String[] args) { </li></ul><ul><ul><li> final double PI=Math.PI; </li></ul></ul><ul><ul><li> final double E=Math.E; </li></ul></ul><ul><ul><li> System.out.println(&quot;E =&quot;+E); </li></ul></ul><ul><ul><li> System.out.println(&quot;Math.exp(1.0) =&quot;+Math.exp(1.0)); </li></ul></ul><ul><ul><li> System.out.println(&quot;PI =&quot;+PI); </li></ul></ul><ul><ul><li> System.out.println(&quot;4*Math.atan(1.0) =&quot;+Math.atan(1.0)); </li></ul></ul><ul><ul><li> System.out.println(&quot;Math.cos(2*PI) =&quot;+Math.cos(2*PI)); </li></ul></ul><ul><ul><li> System.out.println(&quot;Math.sin(PI/2) =&quot;+Math.sin(PI/2)); </li></ul></ul><ul><ul><li> System.out.println(&quot;Math.cos(PI/4) =&quot;+Math.cos(PI/4)); </li></ul></ul><ul><li> System.out.println(&quot;Math.log(E) =&quot;+Math.log(E)); </li></ul><ul><ul><li>System.out.println(&quot;Math.abs(-13.579) =&quot;+Math.abs(-13.579)); </li></ul></ul><ul><ul><li>System.out.println(&quot;Math.floor(13.579) =&quot;+Math.floor(13.579)); </li></ul></ul><ul><ul><li>System.out.println(&quot;Math.ceil(13.579) =&quot;+Math.ceil(13.579)); </li></ul></ul><ul><ul><li>System.out.println(&quot;Math.round(13.579) =&quot;+Math.round(13.579)); </li></ul></ul><ul><ul><li> System.out.println(&quot;Math.pow(25.0,0.5) =&quot;+Math.pow(25.0,0.5)); </li></ul></ul><ul><ul><li> System.out.println(&quot;Math.sqrt(25.0) =&quot;+Math.sqrt(25.0)); </li></ul></ul><ul><ul><li> System.out.println(&quot;Math.random() =&quot;+Math.random()); </li></ul></ul><ul><ul><li> System.out.println(&quot;Math.random() =&quot;+(10*Math.random())); </li></ul></ul><ul><li>} </li></ul><ul><li>} </li></ul>

×