sakthi karthik

+ Follow
since Apr 19, 2008
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sakthi karthik

hi all

my brother passed scjp1.4 in 2006
now he is willing to write new version in scjp
whether he can go for scjp6.0 straight
what is the difference between 6.0 and 6.0 upgrade

thanks in advance
thank you Irina Goble


Originally posted by sree vankadara:
class CardBoard {
Short story=5;
CardBoard go(CardBoard cb){
return cb;
public static void main(String args[]){
CardBoard c1 = new CardBoard();
CardBoard c2 = new CardBoard();
CardBoard c3 = c1.go(c2);
c1 = null;
System.out.println("done!!!"+c1 +c2+ c3);

how many objects are eligible for garbage collection when it reaches end. Also could you pls explain the reason.

4 objects created in the complete program and 2 are available for garbage collection when it reach end.

cardboard object with refernce c1 and story object associated with c1
cardboard object with refernce c2 and story object associated with c2
when c1 = null, the carboard object referred by c1 got abandoned and that object and associated story object are ready for garbage collection.

please correct me if am wrong
its clear and i agree with you but what about that object story.
hi Marco Antonio

i think we can not use void methods in System.out.println().
and in Colours enum there is no setBrilliance() so the compiler take that as just a method. so there is no compiler error.
if you try to invoke setBrilliance() in main() the compiler will say "cannot find symbol". since there is no setBrilliance() in Colours.
if you override that method that will work.

i think so. if its wrong, please tell me.


String s = "doubt"; //object with value doubt

this will create new object with value "DOUBT" and newly created object was assigned to s and the previous object with value "doubt" was abandoned
To shorten or simplify the javac command line, you can specify one or more files that themselves contain arguments to the javac command. This enables you to create javac commands of any length on any operating system.

An argument file can include javac options and source filenames in any combination. The arguments within a file can be space-separated or newline-separated. Filenames within an argument file are relative to the current directory, not the location of the argument file. Wildcards (*) are not allowed in these lists (such as for specifying *.java). Use of the @ character to recursively interpret files is not supported.

When executing javac, pass in the path and name of each argument file with the @ leading character. When javac encounters an argument beginning with the character @, it expands the contents of that file into the argument list.

Example - Single Arg File

You could use a single argument file named argfile to hold all javac arguments:

C:> javac @argfile
This argument file could contain the contents of both files shown in the next example.

Example - Two Arg Files

You can create two argument files -- one for the javac options and the other for the source filenames: (Notice the following lists have no line-continuation characters.)

Create a file named options containing:

−d classes −g −sourcepath \java\pubs\ws\1.3\src\share\classes
Create a file named

classes containing:
You would then run javac with:

C:> javac @options @classes
Example - Arg Files with Paths

The argument files can have paths, but any filenames inside the files are relative to the current working directory (not path1 or path2):

C:> javac @path1\options @path2\classes
thank you marc weber

i was little bit confused when read that chapter first time.
but after i read it second time its clear
your reply helps me as well.
thanks a lot


i think 2 objects are eligible for gc even if we explicitly null c2.
because only two objects were created in that program.

am i right? tell me if am wrong

i can understood that the first path (/dirB) is invalid since it is not the direct subdirectory of root. but why "Specifically, only dirC will be searched, regardless of the current directory." ?
anyone please explain me

Let's use the same directory structure and a different classpath:
/ (root)
|-- dirB

-cp /dirB:/dirA/dirB/dirC

In this case, what directories will be searched if the current directory is dirA? How about if the current directory is root? How about if the current directory is dirB? In this case, both paths in the classpath are absolute. It doesn't matter what the current directory is; since absolute paths are specified the search results will always be the same. Specifically, only dirC will be searched, regardless of the current directory. The first path (/dirB) is invalid since dirB is not a direct subdirectory of root, so dirB will never be searched. And, one more time, for emphasis, since dot (.)
is not in the classpath, the current directory will only be searched if it happens to be described elsewhere in the classpath (in this case, dirC).

anyone please tell me something about @argfiles

thank you Ismael Upright & ivan ivanic
i understand now clearly
if two or more objects has references with each other and when there is no other reference from outside then they are isolated references.

is that right?

thank you once again

hi dinesh

here output is false because equals() method is comparing whether the object a and object b are same. since they are different objects its returning false.

if you import utils to your program you will get Arrays.equals(a,b), here the value stored in a and b are compared

if you are using K&B book, just go throough generics and collections once again.

good luck

sakthi karthik
thank you harshit rastogi
i read generics and collections from K&B book, but still confusing.
can any one tell me difference between arrays and collections.
i got confused when i go through sorting collections and arrays topic
please someone help with simple explanation
so that i can understand this concept easily