kavitha yogaraj

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

Recent posts by kavitha yogaraj

Abimaran Kugathasan wrote:For these question, as Ankit said, search it.

System.out.println is invoking the toString() method of the PriorityQueue, which is using the iterator, which is not guaranteed to respect the natural ordering. From the docs: "The Iterator provided in method iterator() is not guaranteed to traverse the elements of the priority queue in any particular order."So when you print the PriorityQueue with System.out.println(), you won't get order(natural/yours). If you print them manually as Sandra did, you'll get the order!




I agree with this about iterator and not guaranteed behaviour of iterator.
but when pq.poll() method is called (with pq containing a string of char with String type safe) its supposed to remove the highest priority element in that priority queue isn'it?

code: printing manually as Sandra did.

public class PQ1{

public static void main(String [] args){
PriorityQueue<String>pq = new PriorityQueue<String>();
// add elements to pq
pq.offer("one");
pq.offer("twenty");
pq.offer("two");
pq.offer("six");
pq.offer("five");
pq.offer("seven");
pq.offer(" eighty");

System.out.println(pq.poll()+" ");
System.out.println(pq.poll()+" ");
System.out.println(pq.poll()+" ");
System.out.println(pq.poll()+" ");
System.out.println(pq.poll()+" ");
System.out.println(pq.poll()+" ");
System.out.println(pq.poll()+" ");
}
}


will always give unordered output.
But in palce of one two, had I placed 1, 2,80,3,7 then the output is ordered just like how a ideal priorotyqueue as to work.


Hi All,

I was going through PrirotyQueue, I got question in my mind whether queue and all related classes of queue should be learnt or What?

Is it just enough to go through PrirotyQueue?

Sandra Bachan wrote:Based on the discussions on this forum, seems that you have to manually poll() or peek() to have queue printed in order, such as the code below (as)




Output:

1 2 3 4 5 6


This output is perfect only when numbers of Integer class or String class ex- "1" ,"8", "4","2" is considered & the putput wud still be orderd removal by poll()
But when PriorityQueue<String> pq ---->"Seventy", "Six ","One", " Two", like this unordered strings are loaded poll wud worka as deisred. I mean the output of using above code would not produce the ordered removal by pq.poll().
hence the question posed by Sandra Bachan is unanawered. As he/she wanted 2 then 4 to removed.

kindly forgive me if I'm wrong, but I too had the same question wherein I feel Priority Queue would not work for String of chars.

Jim Hoglund wrote:So what happens when you run "java CommandLineTest one two" ?

java CommandLineTest one two" -> this is not what i run.
c:\java\javac Commandline is what I run One two i the output

Jim Hoglund wrote:Isn't CommandLineTest the name of your class?

Jim ... ...



yes, it is the name of my class.

Srinivas Katta wrote:Hi All,

I have Cleared SCJP 6 Exam, I am very happy to see the result, Thanks to all for your Help. Thanks to Java Ranch for hosting these kind of Forums

Thanks
Srinivas



hey do share some experience..
how did you manage to study collections. I looks like very hard chapter
13 years ago
This program was there in www.javachmp.com java test



when I executed this program I had no output
but the output in the exam result is onetwo--
the explaintation is

Be careful of the braces, the System.out.print("--") is not included in the for loop block, so it will be executed once after the loop is finished


java Tester one two

The first argument represents the name of the class, and what come after are the program arguments.

phil sohar wrote:from kathy ............

page no 46........

it can modify a class or method declaration, and that a variable can never be declared strictfp............


but in examlab.........the answer say..........strictfp can be used for instance variable and class.....


which one is correct

Another Interesting point is an Interface can be declared with strictfp but no interface can have strictfp declared method.
An Interface can be strictfp but not its methods.

Bert Bates wrote:I totally agree with "code, code, code"...

One idea is that every mock exam question you look at (whether it's from K&B or some other source), has the potential to be a small program that you can recreate and study, and modify, and test, and in general futz around with. So find a question you have some doubts about, type it in, compile it, run it, tweak it, compile and run again.

hth,

Bert




Thanks Bert,
I would try to get along with the term "code,code,code"... with any question I come accros..
Thank you very much Prasad,

Will try using those ideas while learning n revising. I do write programs as you said(in a limited version). I just want to know any question sets available to do one like self test in our K&B.
Because I'll get turn on to slove more or think towards only when I've questions.

Generally speaking how many months does one require to be ready to take exam? Because I'm gonna out of time within 2 1/2 months to my next quater. And I should be done with this SCJP.


Thanks,
Kavitha
Hi Stephen,

I'm also very beginer to java. But I want to make my career in java. I took basic course in java in my undergrad school. 2 quaters before. Where we all were using IDE. Now I thought of taking SCJP in the summer break of 3 months. Is this possible in this time duartion? since a month I finished untill 6th chap all I'm scoring is 5/9, 6/13, 4/15(a bad score). I'm little tensed infact a little more. If I do this SCJP certification I also reduce one of my undergrad course. So a little burden too. I fell almost I forgot what I read. but when it comes to do assignments like given a question and do programming in java. I can do better. Although going through K&B book is a good experience I dont feel like trying any new programs other than one in the book. How do I practice coding, as you say code, code,code... is there any questrion sets to slove?


I shited to notepad++ where I learnt a lot about errors and mistakes.

I feel I wont suceed! I'm in chap 7th of K&B. Do I need to follow any other books?
What is the mantra???

Ankur kothari wrote:by the way i dont think there will be questions on countries asked in the exam



Ya, I do think the same. Do we have to remember any lang codes or country codes for the exam?
Actually, I want to do using java. As I'm learning java for scjp6 I'd like to do some excersies like this. Yes as you said the changes should propagate to other destination folders .
13 years ago
Hi All,

I do all my java assignments on laptop many of the time and some time I do work on desktop. As my eclipse Ide is stored in local disk c. I don't want to use any hard drive to pick my programs here to there. Instead, I want to program this to happen. So now I want to save my source file(where all my java programs is stored) of laptop to source file of my desktop PC

So to do this. Should I do this -> Write a program to create destination directory in my desktop to copy source directory files of laptop.
Is this enough?
13 years ago
Thanks Again,
13 years ago