Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Randika Isuru

Ranch Hand
+ Follow
since Sep 15, 2013
Randika likes ...
Java Linux Netbeans IDE
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 Randika Isuru

Thank you very much Ulf Dittmer yes that is the reason thanks again

3 years ago
First of all i apologize from Henry. Sorry for my mistake and i 'll check twice where is the suitable forum before i' am going to post my next problem. again sorry for my mistake.

and related to my problem yes I know that NumberFormatException occur because there should be null value or anything other than cannot parse into integer value. but in runtime i gave integer value for that jTextField1 and jTextField2. So inside the NewClass i' am only access the jTextField1 and jTextField2 only. as well as i know getText() method return String and that's why i parse into integer.

my problems are

Then where this runtime error come from?.
if i need to do more exception handling?..
Why this runtime error is occur {reason}?

And also thanks for all of you to take your valuable time for reply me.

3 years ago
Hi folks,

This is very simple java program but I can't handle it very badly. can anyone help me it's highly appreciate I used netbeans IDE for devolp this code

This is my frame class and there are only three labels, three jtextfields and ond one button. what i did is when the button is clicked get the number from what user enter for jtextfield1 and jtextfield2 and add together and return it to jtextfield3. To do this i used separate bean class name called NewClass inside this NewClass there is a method called display() inside this method happens the adding part and return it. that all .
The error is occur in side this class in this line

int no1 = Integer.parseInt(newframe.getjTextField1().getText().trim());

I cannot find the reason why is that any one can hlep.

This is my frame class...

This is my own bean class called NewClass this where adding part is happens.

This is the error what i get from this

java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString( at java.lang.NumberFormatException.forInputString(
at java.lang.NumberFormatException.forInputString(
at java.lang.Integer.parseInt(
at java.lang.Integer.parseInt(
at com.test.frame.NewJFrame.jButton1ActionPerformed(
at com.test.frame.NewJFrame.access$000(
at com.test.frame.NewJFrame$1.actionPerformed(
at javax.swing.AbstractButton.fireActionPerformed(
at javax.swing.AbstractButton$Handler.actionPerformed(
at javax.swing.DefaultButtonModel.fireActionPerformed(
at javax.swing.DefaultButtonModel.setPressed(
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
at java.awt.Component.processMouseEvent(
at javax.swing.JComponent.processMouseEvent(
at java.awt.Component.processEvent(
at java.awt.Container.processEvent(
at java.awt.Component.dispatchEventImpl(
at java.awt.Container.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.LightweightDispatcher.retargetMouseEvent(
at java.awt.LightweightDispatcher.processMouseEvent(
at java.awt.LightweightDispatcher.dispatchEvent(
at java.awt.Container.dispatchEventImpl(
at java.awt.Window.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.EventQueue.dispatchEventImpl(
at java.awt.EventQueue.access$400(
at java.awt.EventQueue$
at java.awt.EventQueue$
at Method)
at java.awt.EventQueue$
at java.awt.EventQueue$
at Method)
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(

I search this in google but i cannot be able to find the proper answer for this.
My error is still occur

3 years ago
Hi folks,

1st of all i need to say i did my OCPJP 1.6 exam with great result with help of this forum. so I thanks ftrom bottom of my heart all of admins of this forum and all other folks, who help me to achive my goal. my next step is do OCEWCD 1.6 and now my problem is are there any specific place in this forum to put all my OCEWCD problem or can i do it just normal way. i mean the same way i put here in my ocpjp problems.
hope you help me this time also to certified OCEWCD as same as before.
long survive!!!

Thanks all
3 years ago
I have passed the OCJP exam with 83%.
And now I decide to do the next step ocpwcd 1.5 but I have some problem 1.5 and 1.6 what is the best version I need to do. I know the latest version is the best one always. But I see in the internet there are no mock exam for ocpwcd 1.6 exam and also still i cannot find good reference book for 1.6. Because I see "Head First Servlets & JSP, Second Edition" book is not good enough for ocpwcd 1.6. But that book OK for ocpwcd 1.5.
am I correct or wrong?
I' am in little bit trouble in this movement
If anybody can give me good advice for what is best one for choose (with reasons) I' am highly appreciate that

Thank you very much Anayonkar Shivalkar

Yes, this is my first exam Anayonkar Shivalkar and also i decide to do the next step ocpwcd 1.5 but i have some problem 1.5 and 1.6 what is the version i need to do. I know the latest version is the best one always but i see in the internet there are no mock exam for ocpwcd 1.6 exam then i' am in little bit trouble in this movement if you can advice to me for what is best one for choose (with reasons) i' am highly appreciate that

and also i received 5 e-mails and i do what they told to me from emails and yes Anayonkar Shivalkar I created the profile. and they send me a confirmation mail for "Your Printed Certification Certificate Request Processed" in that mail thay told me i can get hard copy of my certificate via standard shipping courier to the address what i mention in the my profile.

and also i view my eCertificate using from my account at

but still i' am problem in what i' am mention in my last post. iwhat i mean at my last post as a example, think in my exam there are 10 Thread base question but i have only 5 correctly answered others are wrong. likewise can i get that kind of detail result
is that possible or not ?

anyway thanks again Anayonkar Shivalkar

now Randika Isuru (OCJP 1.6)
4 years ago
Dear Ranchers,

I am writing this with a great pleasure to announce all ranches I have passed the OCJP exam with 83% yesterday.

First of all i need to thank the great people who wrote their Marvels book Kathy and Bert. I' am 100% sure this is the book who need to get great pass for OCJP 1.6. and also there are some people in our country they give a great help for me to achieve this goal.
and finally all kindness Ranchers on this group. without all of you i think passing the exam could be a dream.

OK now i think i can share my experience about this exam. this are the few point what i do before the exam

1). I prepared for the exam for around 3 months
2). Read K&B book thrice,
3). Did all mock tests right after reading each chapter (i do that 3 times).
4). I tried out various mock tests using links found in this forum.
5). I wrote lot of programs to practice and reinforce the concepts learnt.
6). If i get any problem of any question. i google it and try to find the solution. if i couldn't find the answer after google. i wrote my problem in JavaRanch Forums because i' am pretty sure there is someone in this forum can nicely explain solution for my problem.
7). The day before I took the exam, reviewed all 2 minute drills and exam watch notes.

Finally, my efforts did pay off well.

by the way still i have some problem can any one tell me i can review my exam result. But how can i get expandable feedback of my exam result i mean what kind of part i' am week for and what kind part for i' am strong in JAVA can i get what are the question
I did right and what are the wrong is that possible?

until this point that all Ranchers.

Good luck to all who are preparing for the exam.
Many Thanks to all in this forum :-),

Randika Isuru
4 years ago
Hi all can any one tell me why this code give me a compile error

Error is like this cannot find symbol
symbol : method split()
location: class java.lang.String
String[] tokens = args[0].split();
1 error

but if i' am pass in into argument into split() like this

String[] tokens = args[0].split(args[1]);

it's compile no more compile errors

can any one tell me why is that?


Henry Wong Thnank you very much

now i' am very clear about this situation


Henry Wong

can you tell me how compiler read my pattern in this case?

for example like this

Pattern :\d+

"Find one or more digits in a row"

Hi all,

can any one tell me what happen in this code with my command line arguments this is my code

This is my command line arguments

java Regex "\.+ab" "cab4 56 7ab"

But my problem is itz prints only this line..

Pattern is \.+ab

can any one tell me what happen in this code?..

if i put this line to command line arguments

java Regex "\.?ab" "ab4 56 7ab"

itz prints something like this..

Pattern is \.?ab
0 ab
8 ab

ohhhhhhhhh no!!!
i forget that
Thank you very much "Henry Wong"
Hi all,
please any one can tell me why this code give me a output false
are there any thing wrong in my code i don't think so. please correct me

This code give me output : File renamed? false

Thank you very very much Chan... you explain that very nicely..
now i understood all this scenario because of you,,

Thank again...
thank q very much Chan Ag for your responding.
But still i' am little bit unclear about my problem.
so i realize something in your replay. in this case break keyword is not belong to for loop,.. it is belong to switch statement am i correct?
and i try your hint also and also thanks for it
because i understand something in that hint.

so regards your hint what can anybody say about this code

In this case break keyword jump over the for loop and output the result.
what is my problem is why this break keyword do not doing the same thing for switch statement because switch and if both are decision-making statements. i think your referring article say that too.