corejava.pptx

8
String & String Buffer String object is immutable. i.e. Can’t change/modify the content. The methods of String class can’t modify the content of String object. String Buffer object Mutable = Can change content.

Upload: praveen-kumar-reddy

Post on 29-Sep-2015

3 views

Category:

Documents


1 download

TRANSCRIPT

Slide 1

String & String BufferString object is immutable. i.e. Cant change/modify the content. The methods of String class cant modify the content of String object.

String Buffer object Mutable = Can change content.

Type casting Converting a sub class type to super class type Is called Generalization / up casting / widening / implicit casting. It is safe, so no need explicitly casting by programmer. Java compiler implicitly convert.

. Converting a super class type to sub class type Is called Specialization / down casting / narrowing / explicit casting. It is not safe, so programmer explicitly use cast operator.

. If widening is done using sub class object ,only the super class methods are accessible.

If narrowing is done by using super class object ,then none of the super class or sub class methods are accessible. This is useless.

If narrowing is done by using sub class object ,then all the super class or sub class methods are accessible.Exception HandlingPraveen ReddyTryCatchFinally blocks

Throws clause ---- Not Robust programHandle the ExceptionCollection FrameworkSapana Mehta (CS-6V81)InterfacesImplemented classesSetHashSetLinkedHashsetListStackLinkedListArrayListVectorQueueLinkedListMapHashMapHashTableSapana Mehta (CS-6V81)

Retrieving Elements from Collections Using for-each loop

Using Iterator interface

using ListIterator interface

using Enumeration interface

ListIterator is best one

Methods in ListIterator:

boolean has Next()boolean has Previous()element next()element previous()void Remove()ThreadsSapana Mehta (CS-6V81)Light weight process