1 / 154

The Ultimate FREE Java Course Part 2

Have you ever seen a Java course that is 'visual' in nature? The kind of lessons where you can see what happens when you are creating an object, doing method overloading, and using run-time polymorphism. I bet you haven't. Welcome to the most 'visual' Java course you will ever take.<br><br>This course teaches you everything you need to get started with Java programming. It divides each topic into explanation and example.<br><br>The explanation section deals with how a particular concept works in Java and covers the following:<br><br>Data Types & Variables, Typecasting,<br>Operators & Conditional statements such as if, if else, switch<br>Loops such as for, for each, while, and do while<br>Methods, Types of methods, Call by Value vs. Call by Reference, Variable Scope, Method Overloading,<br>Arrays and ArrayLists,<br>Classes and objects, How classes and objects work, and How primitive types vs. reference types are stored<br>Swing classes to take input from the user and command line methods to take input from the user such as BufferedReader, Scanner, Console,<br>Static variables, static methods, this keyword, super keyword, method overriding,<br>What is inheritance<br>And a real world example of run-time polymorphism that actually demonstrates what happens with vs. without polymorphism.<br>The example section covers an example for every concept discussed above. The course will be updated constantly to keep in sync with the real world developments in Java. So, are you ready to become a Java PRO?

coursetro
Download Presentation

The Ultimate FREE Java Course Part 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Free Java Course The Free Java Course that doesn’t SUCK that doesn’t SUCK Part 2 Part 2

  2. Saw Part 1? Part 1 Part 1 covered all the newbie stuff, search for it J

  3. 1. What is a class & Object 2. Buffered Reader 3. Scanner Agenda 4. Array List 5. Call By Value vs. Reference 6. Constructors & Overloading 7. Static keyword

  4. 8. Enumerations 9. Scope vs. Lifetime 10. This keyword Agenda 11. Inheritance 12. Method overriding 13. Super keyword 14. Polymorphism

  5. Where do I watch these videos? coursetro.com

  6. What is a class? Simple = Grouping the Java data types to make your own types Complex = Trying to mock items in the real world… coursetro.com

  7. What is your job? Take something in the real world and try to represent it in code coursetro.com

  8. 1 What does it have? 1 What does it have? (Noun) [Properties] 2 What does it do? What can you do 2 What does it do? What can you do with it? with it? (Verb) [Methods] coursetro.com

  9. What does it have? What does it have? (Noun) [Properties] Model Size (Width, height, length, breadth…) Weight … coursetro.com

  10. What does it do/you can do What does it do/you can do? ? [Methods] [Methods] Call Call Sms Sms Take pictures/videos Take pictures/videos Play games Play games … … coursetro.com

  11. 1 What does it have? 1 What does it have? (Noun) [Properties] 2 What does it do? What can you do 2 What does it do? What can you do with it? with it? (Verb) [Methods] coursetro.com

  12. 1 What does it have? 1 What does it have? (Noun) [Properties] Author Number of pages Publication name Title … coursetro.com

  13. 1 What does it do or you can 1 What does it do or you can do with it? do with it? (Verb) [Methods] Read Make Notes … coursetro.com

  14. Ask this question every time… Take anything in the real world, it can be a real object or a virtual tank inside your favorite game. What does it have? What does it do or what can you do with it? coursetro.com

  15. class class Phone{ //What does it have //What does it have? Properties ? Properties String model; double weight; … //What does it do or you can do //What does it do or you can do? Methods ? Methods public void call(){…}; public void sendSms(){…} public void takePictures(){…} public void playGames(){…} } coursetro.com

  16. class class Book{ //What does it have //What does it have? Properties ? Properties String author; int pages; String publicationName; String title; //What does it do or you can do //What does it do or you can do? Methods ? Methods public void read(){…}; public void makeNotes(){…} } coursetro.com

  17. First First Name Name Last Last Name Name Age Age Occupation Occupation Class Software Engineer Mark Murphy 35 Object 1 Jon Skeet 40 Developer Object 2 Frank Underwood 60 Congressman Object 3 Raymond Tusk 65 Entrepreneur Object 4 Zoe Barnes 30 Journalist Object 5 coursetro.com

  18. The Conclusion Class = Object = You create a type You use your created type coursetro.com

  19. Google It! 1. java class vs object 2. Java class vs method 3. Java class vs type 4. Java instance variable 5. Java instance method 6. difference between classes and objects 7. identifying classes and objects in ooad

  20. How to make a Class? How to make a Class? class class Book{ //What does it have //What does it have? Properties ? Properties String author; int pages; //What does it do or you can do //What does it do or you can do? ? Methods Methods public int getPages(){…}; public void setPages(int number){…} } coursetro.com

  21. How to make an Object? How to make an Object? Book one = new Book(); Book one = new Book(); Book two = new Book(); Book two = new Book(); Book mine = new Book(); Book mine = new Book(); Book yours = new Book(); Book yours = new Book(); coursetro.com

  22. When you make an object… Book one; null one one = new Book(); one Herbert Schildt one.author = “Herbert Schildt”; one author Herbert Schildt author one.pages = 1000; one pages = 1000

  23. When you make an object… Book two; null two two = new Book(); two J K two.author = “J K Rowling”; two author Rowling J K author two.pages = 1500; two Rowling pages = 1500

  24. Adding a method (accessor/getter) class class Book{ J K String author; author two Rowling int pages; pages = 1500 public public int int getPages getPages(){ (){ return pages; return pages; int getPages() } } } coursetro.com

  25. Using a method public static void main(String[] args){ J K Book two = new Book(); author two Rowling two.author = “JK Rowling”; pages = 1500 two.pages = 1500; …println(two.getPages() two.getPages()); int getPages() } main()

  26. Adding a method (mutator/setter) class Book{ J K String author; author Rowling int pages; pages = 1500 two public int getPages(){ int getPages() return pages; } void setPages(int) public void public void setPages setPages( (int int number){ number){ pages = number; pages = number; } } coursetro.com }

  27. Using a method public static void main(String[] args){ J K Book two = new Book(); author Rowling two.author = “JK Rowling”; pages = 2000 two two.pages = 1500; int getPages() two.setPages two.setPages(2000); (2000); …println(two.getPages() two.getPages()) //2000 void setPages(int) } 2000 main()

  28. User will give you length of each side/no of sides 1 side = Take that as the side of a square or Solve this problem radius of a circle 2 sides =Length and breadth of rectangle 3 sides= sides of triangle. Any other number of sides = Invalid Input Find the smallest, largest and average area. Find the smallest, largest and average area. coursetro.com

  29. What do we know from the problem? There are 4 shapes : circle, rectangle, square and triangle… coursetro.com

  30. Let’s start with Square What does a square have? What does a square have? Length of each side Diagonal length Angles Area Perimeter … coursetro.com

  31. Let’s start with Square What can you do with a square/square do? What can you do with a square/square do? Calculate Area Calculate perimeter … coursetro.com

  32. Google It! 1. What is a getter and setter method? 2. what is accessor and mutator method in java 3. java data members definition 4. java instance method 5. java dot operator 6. where are java objects created 7. java new keyword

  33. What is a Stream? InputStream Your Program Data Source 0011 0101 1110 1111 0000 0110 1100 1010 1011 OutputStream coursetro.com

  34. InputStream: Reads only 0s 1s InputStream 0 1 0 0 1 0 1 1 0 coursetro.com

  35. InputStreamReader InputStream Input Stream Reader 0 1 0 0 1 0 1 1 0 H i T h e r e ! Take the binary 0s and 1s from Input Stream and give you characters, But only 1 character at a time

  36. BufferedReader Input Stream Input Stream Reader Buffered Reader 0 1 0 0 Wh a t What Take the characters from InputStreamReader and read the entire line in a single shot…

  37. Need BufferedReader object BufferedReader BufferedReader reader = new BufferedReader BufferedReader(…); coursetro.com

  38. Need InputStreamReader InputStreamReader InputStreamReader isr = new InputStreamReader BufferedReader reader = new BufferedReader(isr InputStreamReader(…); isr); coursetro.com

  39. Need InputStream InputStreamReader isr = new InputStreamReader(System.in BufferedReader reader = new BufferedReader(isr); System.in); coursetro.com

  40. How do I take input? …println(“Enter your name”); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String yourName = br.readLine br.readLine(); coursetro.com

  41. Scanner y r I am 2 6 y r I am 2 6 Scanner Take characters, split everything on the basis of ‘spaces’ by default

  42. How does it work? System.out.println(“Enter whatever you want…”); Scanner scan = new Scanner(System.in); Scanner scan = new Scanner(System.in); Enter whatever you want… I am 26.5 years old! I a m 2 6 . 5 y e a r s o l d ! After user hits enter, scanner splits input on the basis of spaces I a m y e a r s o l d ! Each part is called a token, scanner has 5 tokens 2 6 . 5 Use the next next() method of the Scanner Scanner class to get each token

  43. Click to watch videos below Classes and Objects Explained I Classes and Objects Explained II Classes and Objects Example Take Input From User Explained Take Input From User Example

  44. Google It! 1. 2. Java InputStream 3. Java OutputStream 4. Java BufferedReader 5. Java Scanner 6. Java Console 7. java scanner ioexception 8. bufferedreader vs scanner vs console 9. Scanner next java 10. Scanner nextLine what is a stream in java

  45. Why Array List? No need to worry about the size…Also be very specific about what type of elements you can store coursetro.com

  46. Auto boxing and unboxing Primitive Primitive Type Type byte short int long float double char boolean Wrapper Wrapper Class Class Byte Short Integer Long Float Double Character Boolean Double wrapper = = 31.25 value Double wrapper = 31.25; //Putting number into a box = autoboxing double d = wrapper; //Removing number from box = unboxing coursetro.com

  47. How to make one? ArrayList list = new ArrayList(); //stores anything and everything ArrayList<String> list = new ArrayList<>(); //stores only Strings ArrayList<Integer> list = new ArrayList<>(); //stores only Integers coursetro.com

  48. Method Method Name Name What does it do? What does it do? add Adds element to the end of the ArrayList clear Removes all elements from ArrayList contains Returns true if ArrayList contains the element you specified, else false get Returns the element at the index you specify indexOf Returns index of first occurrence of the element you specified in the ArrayList remove Either specify the element and remove it when it occurs first or specify the index and remove the element at the index size Number of elements stored trimToSize Trim ArrayList to current number of elements

  49. Lights! Camera! Action! ArrayList<String> list = new ArrayList(); list list.add(“red”); list.add(0, “yellow”); list.add(“green”); list list list red yellow yellow red red green list.remove(1); list.remove(“green”); list.contains(“yellow”) list list yellow yellow green true coursetro.com

  50. For each loop String[] list =new String[10]; … ArrayList<String> list = new ArrayList<>(); … for(String item : list){ ...println(item); } for(String item : list){ …println(item); } coursetro.com

More Related