Presentation is loading. Please wait.

Presentation is loading. Please wait.

Elipses int... passed into method as int[]

Similar presentations


Presentation on theme: "Elipses int... passed into method as int[]"— Presentation transcript:

1 Elipses int... passed into method as int[]
Object... passed into method as Object[] Date... passed into method as Date[] etc.

2 Casting Casting down may be done ONLY down the class hierarchy.
Casting up is not required because a subclass object may always be stored in a superclass reference (or an interface that it implements).

3 Reflection If your program is written well and adheres to the principals of polymorphism, then you don't really need reflection. It's nice to know you have it when testing/debugging though.

4 Recursion Often times recursion is simpler than iteration.
Certain applications require recursion, such as binary trees. Let's see some examples. break to code. 4

5

6 Intro to Data Structures in Java
Single Lined List Stack Binary Tree others...

7 Inner and Anonymous Classes
Though you are captive in the OO paradigm, you can use inner classes and anonymous classes to get around this constraint and write procedural-like code. Often times, no one but the enclosing class cares about an object. In this case, you may consider using inner or anonymous classes.

8 WindowsBuilderPro by Google
WB/release/R /3.7/ b,y,c,n,s,l,d,f,str; get rid of these in Window || Preferences || Java || Code Style || Fields. Otherwise, they will hose you in WB.

9

10 Constructors Constructors are optional. If your class is just a static driver; i.e. it just has a static main method, then no need to instantiate it; and no need for constructor. If your class is a "java bean" -- a class that models a real world object (noun) in your system, then it should have a constructor. House, Car, Person, etc. If you don't provide a constructor, a no-args constructor is provided automatically. You can, and often want, more than one constructor with different signatures. You call a constrcutor with the 'new' keyword.

11 Model a system Object-oriented programming is about modelling a system. Write the problem out as requirements -- this will essentially be a math world problem (your favorite kind to solve!) Your computer objects map directly to real- world objects (nouns). Your methods map directly to real-world actions (verbs).

12 Build a GUI using WindowBuilder and Swing.
Write a very simple application for a contact manager. The the sake of simplicity, each contact will have a name and a phone number only. The user should be able to create new contacts and diplay all contacts. Build a GUI using WindowBuilder and Swing. Solve a simple word problem. Red are verbs and blue are nouns. Model the system! Nouns are either objects or fields (properties of objects). Verbs are methods. 12

13 Interfaces A class implements an interface rather than extends it. Any class that implements the interface must override all the interface methods with it's own methods. Interface names often end with "able" to imply that they add to the capabilty of the class. An interface is a contract; it defines the methods

14 Class Objects

15 The ColorSelector GUI App

16 The Leet Translator GUI App

17


Download ppt "Elipses int... passed into method as int[]"

Similar presentations


Ads by Google