cs211sp08-01 - CS 211 Java overview very quick overview of...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 211 Java overview very quick overview of Java basics actually use inheritance and interfaces intro to threads GUIs recursion/induction, efFciency, sorting data structures (lists, queues, stacks, trees, etc) graph algorithms applications LOTS of programming ! 1 CS 211 - Spring 2008 Books etc.- at java.sun.com /reference/api /docs/books/tutorial- IDE from www.eclipse.org- The Java Language SpeciFcation (Gosling et al)- Data Structures and Algorithm Analysis in Java (Weiss) 1 CS 211 Java overview Java uses classes and objects = hyper organised ! A class Car is like a manufacturer who only construct s individual new cars. A class Bucket will only construct individual new buckets. Cars and buckets have natural things which belong to every car or bucket, although of course cars have different colours, etc.! 2 2 CS 211 Java overview To build a red car called ferrari, we might write Car ferrari = new Car(red);- Im not promising that this will work!!!! and to build a yellow car called ccbb, we might write Car ccbb = new Car(yellow); Of course, Bucket rollsroyce = new Bucket(huge); will only give you a peculiarly named huge bucket. If you want to access stuff in your car, then the dot is the genitive case, so ferrari.colour would be red, and ccbb.colour would be yellow. This is also like a path ; looking into the ferrari or the ccbb to Fnd the individual colours. More on this later ..... . 3 3 CS 211 Java overview Enough of such generalities! How do we write a simple program in Java? First we need to be able to get stuff in to and out from the computer! System.out.println ( Once upon a time ... ) ; looks into the System where it nds an out , and looks into System s out where it nds a method (or function or routine ) which can print a String of characters onto a fresh line on the standard output screen. System.out.print ( Golly gosh ) ; does exactly the same, except the method print doesnt nish with a new line. 4- i /o 4 CS 211 Java overview To read in a String of characters from the standard input keyboard, InputStreamReader nab = new InputStreamReader(System.in); BufferedReader grab = new BufferedReader(nab); constructs a BufferedReader called grab so that grab.readLine( ); reads a whole line of input. Java is a language of lets pretend!, so grab is a virtual keyboard which has the ability (amongst other skills) of readLine( ) - all the other stuff is there to establish a connection between make believe and reality. 5- i /o 5 CS 211 Java overview We can do the same thing with fles, FileReader secret = new FileReader ( spy.oops ) ; BueredReader james = new BueredReader (secret) ; constructs a BueredReader called james so that james.readLine( ) ; reads a whole line o input rom spy.oops . As a matter o common courtesy, you should secret.close( ) ; close the fle when youve fnished with it! close the fle when youve fnished with it!...
View Full Document

Page1 / 29

cs211sp08-01 - CS 211 Java overview very quick overview of...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online