Ben Pittens

+ Follow
since Jan 03, 2016
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 Ben Pittens

Hi Henry,

While the LinkedList class supports both the List and Queue interface, you can't use the List interface to get to Queue interface methods. You need to declare the reference variable as Queue or LinkedList type.

Off course, I allready tried a reference to the ArrayDeque but that didn't work, but the ArrayDeque is not an interface and I think it doesn't inherit from LinkedList either.
I thought I also tried the reference to the Queue interface and to the LinkedList but maybe I made a typo or something, or something else was wrong in my Eclipse code editor. Now it works.

Thanks very much for your fast response!! I can go on now with the OCP training.

Kind Regards

I am back again, couple of months ago I graduated for my OCA now I am working on my OCP. Off course I use the OCP book of Jeanne and Scott. OCA book worked good for me, and the OCP book seams also ok to me. I read 4 chapters. And it is easy to read.

I have a question about page 138 of the OCP book.

At page 138 there is stated, we skip the LinkedList code. But I need a hand because if I wanted to use the LinkedList as a queue things don't work:

I guess I do something very stupid, but I can't find out what. Can anybody give me a hand?

Thanks in advance
Kind Regards

I want to replace this curl command with a request in a Java client:

curl -k --user userName:SecretID –d "scope=/LeverdatumbepalingRest/api/v1.0/"

It is returning an JSON message and it look like this:

{ "token_type":"bearer", "access_token":"AAEecmVzdC10b2tlbi1zcnYtcGFzc3dvcmQtY2xpZW50zBVd4EcoSnA5zVHOHSMkSN-ReEgOnAuyQxv3jv613vQvonMGU_HxjWbzNJPfadc1L0ZSA4dar0YCR8Jx7PSvkue_2Lh7lOQ9Nv8KGRz092OgLR_A2TGD6e6zafsgpaMB", "expires_in":2678400, "scope":"/LeverdatumbepalingRest/api/v1.0/" }

The request goes to a IBM Datapower server with an webtoken implementation.

I tried it in Java with Apache oltu lib: org.apache.oltu.oauth2.client-1.0.1.jar

I tried to build a Java client with this code but it is not working, the server even does not receive any message so my client is not working:

This error I am getting:

Exception in thread "main" OAuthProblemException{error='unsupported_response_type', description='Invalid response! Response body is not application/json encoded', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}}
at org.apache.oltu.oauth2.common.exception.OAuthProblemException.error(
at org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse.setBody(
at org.apache.oltu.oauth2.client.response.OAuthClientResponse.init(
at org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse.init(
at org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory.createCustomResponse(
at org.apache.oltu.oauth2.client.URLConnectionClient.execute(
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(
at nl.sligro.leverdatumbepaling.test.LDBGetCertificaat.callGetToken(
at nl.sligro.leverdatumbepaling.test.LDBGetCertificaat.main(

Any body have an idea whats wrong with my code?

Thanks in advance,

Kind Regards,

5 years ago
Hello Winston,

I have solved this, there was an error in an other part off the code. I had a file open for writing but did not write in append mode so every thread was over written the exsisting file and that doesn't work in this case. The file is in append mode now and now everything is running fine.
Yes I know about the exceptions, I have to work that out a little better.

Thanks for your help.

Kind regards
5 years ago

If I run this code:

Then I should expect that the threads are executed in the order they are started:
Object ADAuthenticator with argument i = 0 first, then Object ADAuthenticator with i = 1, then Object ADAuthenticator with i = 2 and so on.

But it seams to me that the order is nog in line with the calls. It seams that ADAutenticator with i = 15 is started before ADAutenticator with i = 0.
Like you see I also used a thread.sleep to be sure that they are launched in the order I wanted them to launch. But with no succes.

What I am doing wrong, how can I be sure that thread with object ADAuthenticator i = 0 starts at first and ADAuthenticator i = 1 next and so on ?

Kind Regards
5 years ago
hi Fred,

Yes of course that's the easiest way to do:

And the answer is that code change and compilation after start JVM are irrelavant to allready running code.

Kind Regards
5 years ago

I have a very long running Java job A in a JVM in Eclipse. (Run as -> Java Application). So this code runs.
Let's say the compiled code where Job A runs on is in the "foo.class" file.

What is happening if I change the code in "" file, and save it in Eclipse so it will be compiled to the class file "foo.class". So the "foo.class" file is changed actually.

What's happening in the running job A: Is job A using the changed code of "foo.class" or does it use just the code of "foo.class" like it was at the moment when Job A was started at runtime?

Kind regards
5 years ago

Thanks again and thanks for the cow.
Yes I like a "Rochefort 10"(dark belgian beer) for a cold dark winter evening like this.

I submitted my name and story to the Wall of fame.

I also just bought the Java OCP Programmer II book of Jeanne and Scott at Amazon.
Next step....

Kind regards
5 years ago


This morning I passed the OCA test with a score of 72%!!!

I am happy with that result after a very busy month with studying a lot and also working 40 hours a week!

I would like to thank all the people who helped me at the coderanch, speciall thanks to Roel, Jeanne, Scott and Ramya.
Your answers and tips helped me a lot! I really appriciate that.

Here is how I did my preperation: its a little contribution to this site. Maybe its interesting for people who also want to go for the OCA certificate:

Before I started this study, my basics are c# medior level programmer and Java Junior level programmer. I only learned Java OOP at high school with a little practical experience in Eclipse.
My normal job is System integrator(I work with linux Redhat, IBM Datapower and IBM MQ systems). If I have to create a service for integration tests I use Java(last time I used Java is about 3 months ago).

20 december I received the Java book ordered at Amazon: "OCA Oracle Certified Associate Java SE 8 Programmer 1 Study guide" written by Jeanne Boyarsky and Scott Selikoff: B&S book.
21 december I bought the Ethuware practice kit for 12,00 euro.

23 december 2015 until 3 jan 2016
I studied 10 days(Average of 9 hours a day) real hard in the B&S book. I went through all the theory and after each chapter I made all the questions of that chapter when possible work things out in a simple notepad texteditor. Not yet Eclipse, just only the text editor at that moment.
Then I did some Ethuware tests. That was bad news: between 40% and 50% score. I did also the flashcards at the Sybex-Wiley testbank. That result was good. But that is an easy job.

4 - 10 january 2016
I looked for what I did wrong in the Ethuware tests and tryed to update that part of my Java knowledge by again studying the B&S book. Every evening I read a chapter and did the exercises again in the B&S book. And a deepdive in the questions at each chapter and some practical input in trying different variants in a notedpad code editor.
At saterday and sunday I practised the whole day in Eclypse Mars and also the notepad editor.

At 10 januari I did practal exam 1 of the Sybex-Wiley testbank: Result 56%. A little better but not good enough.

11 - 17 januari 2016
I did some Ethuware exercises and looked for what went good and what not and why.
In this week I read the B&S book for the thirth time and I was in a stage that sometimes I knew what was stated on the next page. And again did the exercises by creating variants of it.
At 16 and 17 januari I did at the Sybex-Wiley testbank website, Pacticum Exam 2 and 3 and reached an average score of 68%.
Good enough according the advices of Jeanne to go for the gold.

18 january 2016 I did the test!
My worst Enemy was the time. You really have not much of time for each question. Because I live in the netherlands(No English speaken country) i get an exam time of 150 minute(2,5 hour) for 77 questions.
So at last I had to gamble for 7 questions because I was running out of time. Else my score would be higher. But nevertheless its a part of the job that you have a limited time.

In mine opinion the Ethuware tests are much havier as the real exam, they go much more into detail, but they are good for training. The Sybex Wiley testbank come close to the real experience.
And the B&S book fits for this job, its excellent written. Its worth 5 stars at Amazon! Java is not such an easy language for me but the B&S book made it clear for me.

Thanks and lets go for the OCP job!! First a couple of beers this evening.

Kind Regards
5 years ago

Little complain about the Sybex Testbank:

I started this morning at 8.30u CET with Practice test 2. Test 2 was finished by me at 10.15u CET. After the test I evaluated my result.
Then I started to view the answers one by one with the "next question button", untill I had viewed all the answers at 12.15u CET.

After that I clicked the "Result screen" button again and the Sybex site give me the message "Session timed out".

So I had to log back in again, but all my answers where lost. That is a little troublesome.

It happens a couple of time if you are in the questions that if you go back to the review screen that you ar thrown out.

What are the triggers for a timed out session?

Kind Regards
Thanks that helps a lot,

So I can also give it 3 params and even another interface calc with 4 params ike this?

I thinks I fully understand this now.


Hi Roel and Ramya,

Nice to see those examples, now it is clear to me how the list.toArray() method works.
Kind Regards

I have a question about the length(number of slots) of an array when it is created through a list.toArray.

After this I have an array str4 with 4 elements "Dog", "Cat", "Monkey", "Elefant".
For me that is strange because I dimensioned it with "new String[1]" as a parameter of the toArray function !
I should excpect that only the "Dog" is in the array because the length of the str4 array is 1.

What use it has then to set a dimension parameter like in new String[1] ?
Does that parameter mention something else?

Kind Regards

Hello Ramya,

Thanks, Ok, yes I allready mentioned that about the fact that the code is not complete, some parts are not displayed.
And te curly braces was a typo.

Kind regards

In the book Boyarsky and Selikoff I found something I think it is not completely correct.

In the code example look like this.

I think this code doesn't compile because in the finaly clause an checked exception is thrown and it is not handled.
Nevertheless because de method declaration is not shown we can't see if the method might throw a exception.
Is that correct?

I Didn't find this on de eratta list of the book.Erratta list book

Kind regards