Mobile         Software      EngineeringL02 – Java Primer                  Mohammad Shaker           FIT of Damascus - AI ...
IDEeclipse, netbeans, etc.
eclipse
eclipse Juno, 2012
btw, why eclipse?!
eclipse Download  http://www.eclipse.org/
eclipse Download
eclipse Juno – Packages and Projects
JavaJVM – Java Virtual Machine
JavaWrite once, run anywhere
Javaeverything is an object!        Or is it?
Javaeverything is an object!        Or is it?
API        http://java.sun.com/javase/6/docs/api/                    Tutorialhttp://java.sun.com/docs/books/tutorial/java/...
Variables - Naming•   Subsequent characters also can be numbers•   Case sensitive•   No spaces•   Examples:    name    fir...
Reserved Wordsabstract        continue             for             new            switchassert***        default          ...
Primitive Typesbyteshortintlongfloatdoublebooleanchar
Primitive Typesbyteshortint               Everythinglong                 is anfloat              object?doublebooleanchar
Primitive Typesbyteshortint               Everythinglong                 is anfloat              object?doublebooleanchar
ObjectsStringBigDecimal
Arraysint[] grades;grades = new int[15];
Control flowif (boolean) {  // perform this code} else {  // otherwise, run this}
Example on first step!Car myCar = new Car();
Example on first step!Car myCar = new Car();
Example on first step!Car myCar = new Car();Car yourCar = myCar;Point loc = myCar.getLocation();
New paradigms• Stack• Heap• Garbage collection
Setters and Getters
Let’s get our hands dirty
Let’s get our hands dirty         Objects
Packages vs Namespaces
void main(string[] args)
Instance vs Class methods    void shootBall(Point point)  static void main(string[] args)
Inheritance and Polymorphism     extends, super, @Override
Some diff.protected in a form of package scope not class scope
Some diff.final vs const vs readonly
interfaces
Interfaces extends
Collections
http://docs.oracle.com/javase/tutorial/collections/interfaces/index.html
ExampleArrayList<String> arrList = new ArrayList<String>();arrList.add(“A”);arrList.add(“AB”);arrList.add(“ABC”);arrList.a...
Example• Suppose an ArrayList A1• What does the following line mean?List<String> list =                     new ArrayList<...
for-each Construct• Looping by indices• for-each, parallel execution  for (Object o : collection)     System.out.println(o);
Collection OperationsList<Type> list1 = new ArrayList<Type>();// …List<Type> list2 = new ArrayList<Type>();// …List<Type> ...
List Algorithms•   sort — sorts a List using a merge sort algorithm, which provides a    fast, stable sort. (A stable sort...
Iterators
Multithreadingsynchronized, wait, notify, notifyall
Exception Handling, IO...
Design PatternsSingleton, Factory, Proxy, Template.. etc.
Gang of four
Implementing Singleton with Java            “live”
Thx for listening
Mobile Software Engineering Crash Course - C02 Java Primer
Mobile Software Engineering Crash Course - C02 Java Primer
Mobile Software Engineering Crash Course - C02 Java Primer
Upcoming SlideShare
Loading in …5
×

Mobile Software Engineering Crash Course - C02 Java Primer

573 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
573
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mobile Software Engineering Crash Course - C02 Java Primer

  1. 1. Mobile Software EngineeringL02 – Java Primer Mohammad Shaker FIT of Damascus - AI dept. MohammadShakerGtr@gmail.com Mobile SE – August 2012
  2. 2. IDEeclipse, netbeans, etc.
  3. 3. eclipse
  4. 4. eclipse Juno, 2012
  5. 5. btw, why eclipse?!
  6. 6. eclipse Download http://www.eclipse.org/
  7. 7. eclipse Download
  8. 8. eclipse Juno – Packages and Projects
  9. 9. JavaJVM – Java Virtual Machine
  10. 10. JavaWrite once, run anywhere
  11. 11. Javaeverything is an object! Or is it?
  12. 12. Javaeverything is an object! Or is it?
  13. 13. API http://java.sun.com/javase/6/docs/api/ Tutorialhttp://java.sun.com/docs/books/tutorial/java/TOC.html
  14. 14. Variables - Naming• Subsequent characters also can be numbers• Case sensitive• No spaces• Examples: name firstName phoneNumber
  15. 15. Reserved Wordsabstract continue for new switchassert*** default goto* package synchronizedboolean do if private this break double implements protected throw byte else import public throws case enum**** instanceof return transient catch extends int short try char final interface static void class finally long strictfp** volatile const* float native super whilehttp://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
  16. 16. Primitive Typesbyteshortintlongfloatdoublebooleanchar
  17. 17. Primitive Typesbyteshortint Everythinglong is anfloat object?doublebooleanchar
  18. 18. Primitive Typesbyteshortint Everythinglong is anfloat object?doublebooleanchar
  19. 19. ObjectsStringBigDecimal
  20. 20. Arraysint[] grades;grades = new int[15];
  21. 21. Control flowif (boolean) { // perform this code} else { // otherwise, run this}
  22. 22. Example on first step!Car myCar = new Car();
  23. 23. Example on first step!Car myCar = new Car();
  24. 24. Example on first step!Car myCar = new Car();Car yourCar = myCar;Point loc = myCar.getLocation();
  25. 25. New paradigms• Stack• Heap• Garbage collection
  26. 26. Setters and Getters
  27. 27. Let’s get our hands dirty
  28. 28. Let’s get our hands dirty Objects
  29. 29. Packages vs Namespaces
  30. 30. void main(string[] args)
  31. 31. Instance vs Class methods void shootBall(Point point) static void main(string[] args)
  32. 32. Inheritance and Polymorphism extends, super, @Override
  33. 33. Some diff.protected in a form of package scope not class scope
  34. 34. Some diff.final vs const vs readonly
  35. 35. interfaces
  36. 36. Interfaces extends
  37. 37. Collections
  38. 38. http://docs.oracle.com/javase/tutorial/collections/interfaces/index.html
  39. 39. ExampleArrayList<String> arrList = new ArrayList<String>();arrList.add(“A”);arrList.add(“AB”);arrList.add(“ABC”);arrList.add(“ABCD”);// using indicesarrList.set(0, arrList.get(1));arrList.set(1, “foo”);// out of bound?arrList.set(9, “bar”);
  40. 40. Example• Suppose an ArrayList A1• What does the following line mean?List<String> list = new ArrayList<String>(A1);
  41. 41. for-each Construct• Looping by indices• for-each, parallel execution for (Object o : collection) System.out.println(o);
  42. 42. Collection OperationsList<Type> list1 = new ArrayList<Type>();// …List<Type> list2 = new ArrayList<Type>();// …List<Type> list3 = new ArrayList<Type>(list1);list3.addAll(list2);
  43. 43. List Algorithms• sort — sorts a List using a merge sort algorithm, which provides a fast, stable sort. (A stable sort is one that does not reorder equal elements.)• shuffle — randomly permutes the elements in a List.• reverse — reverses the order of the elements in a List.• rotate — rotates all the elements in a List by a specified distance.• swap — swaps the elements at specified positions in a List.• replaceAll — replaces all occurrences of one specified value with another.• fill — overwrites every element in a List with the specified value.• copy — copies the source List into the destination List.• binarySearch — searches for an element in an ordered List using the binary search algorithm.• indexOfSubList — returns the index of the first sublist of one List that is equal to another.• lastIndexOfSubList — returns the index of the last sublist of one List that is equal to another. See more @ http://docs.oracle.com/javase/tutorial/collections/interfaces/list.html
  44. 44. Iterators
  45. 45. Multithreadingsynchronized, wait, notify, notifyall
  46. 46. Exception Handling, IO...
  47. 47. Design PatternsSingleton, Factory, Proxy, Template.. etc.
  48. 48. Gang of four
  49. 49. Implementing Singleton with Java “live”
  50. 50. Thx for listening

×