Laur Alex

Greenhorn
+ Follow
since Oct 16, 2016
Merit badge: grant badges
For More
Bucharest, Romania
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Laur Alex

As a conclusion it seems that because our "comparator" all the time it is returning a positive number (maximum between 2 positive numbers - because all the elements in our stream are positive), and when it comes to Stream.max() he is searching to find the maximum using the comparator using the contract we all know (-negative number, 0 , positive number), which is returning all the time a positive number,  which is resulting that any 2 numbers compared are in reverse order and thus the first number from stream is always the maximum which is "1" in our case. Being in place those all above conditions, is correct that this piece of code is always return the first element from stream (i need to admit that i have tested this), did i've judged correctly ? If yes, thank you  gentlemens.

Hi everybody,

Can anyone see why this piece of code is returning value "1"?



I've checked Java Api 8 and i have found that Integer::max it is returning the maximum between 2 numbers just like Mat.max() , and Stream.max() is returning the maximum performed by the above "comparator" behavior. I miss something and i can't figure it out what, if somebody can explain.
From my perspective it should print 7 but the code prints 1.


Hello guys,


Why when you say pool.remove(r) doesn't throw ConcurrentModificationException? It appear that you get the inner object iterator with forEach and in the same time you remove an element  pool.remove(r).

Thanks in advanced!

7 years ago

Jeanne Boyarsky wrote:

Laur Alex wrote:Thanks a lot Mr. Boyarsky! I need to confess that i haven't seen the exercices until now. In this case this book gives me a great confidence!


Ms Boyarsky. (Or Jeanne; no need to be formal!) I'm female. And you're welcome.


I'm sorry for mistake. In my country doesn't exist this kind of names.
I hope you already forgived me.
7 years ago

Jeanne Boyarsky wrote:The Murach series of books ends each chapter with a bunch of good hands on exercises. They have a Servlet/JSP titlethat I think you'd like from your post description.



Thanks a lot Mr. Boyarsky! I need to confess that i haven't seen the exercices until now. In this case this book gives me a great confidence!

Wish the best!
7 years ago
Hello guys,

I'm comming with a question about what book can i purchase with a lots of exercices and compiling in java ee?
I need to mention that i have readed Thinking in java by Bruce Eckel and solve all the exercices . It makes a great job with a lot of examples and almost 450 exercices on each topic or concept for a beginner.
Can you recommand me please another book with servlet and jsp  just like Thinking in java?
I have already purchased Head first Servlet and JSP and Murach's servlet and jsp 3rd edition but i can't see any strong challenging exercices in those books.

Thanks!
7 years ago

Henry Wong wrote:

Laur Alex wrote:Why we don't need volatile for "Meal meal;" in Restaurant class ? Can you explain why, please?



From my previous response...

Henry Wong wrote:
For the first, yes, you don't need volatile, if synchronization is done correctly. And the reason is because the locks (either type) sync memory correctly too.



Henry



So any memory is under any syncchronized block or method or exclusive lock,  it's sync! Thanks!

Henry Wong wrote:
Not sure what are you asking?

Are you asking/confirming, if synchronization is done correctly, you don't need volatile? Or are you asking why you don't need volatile? For the first, yes, you don't need volatile, if synchronization is done correctly. And the reason is because the locks (either type) sync memory correctly too.

Henry



Why we don't need volatile for "Meal meal;" in Restaurant class ? Can you explain why, please?
Hello guys,

With all respect for you!

Please help me to understand why they didn't used the word "volatile" in this context for  "Meal meal;" from the Restaurant class . I know that if you change a value for a state within an object from a task and trying to read from another task, there will be visibility problems (it's about flushing within processor registry) and if the situation allow,  you can use volatile but must be aware. More safer is to use synchronized. If that field is guarded by the synchronized method or block, it's not necessary to use volatile. Please help me to understand why this code (compile and) run correctly and giving the corect result (run for more than 1 time -> same results) without using the volatile keyword for " Meal meal;" from Restaurant class. It's enough to change the state under any sycnhronized method and doesn't count if the keys are not taken for the object who's own those states who are going to be modifyed from another task? If you can observed i tryed also with exclusive Lock objects and Conditional. Am i missing something?

Here is the code and after this is the complete code that compile and runs correctly.



Here is the complete code to make your idea. This code is just like producer and consumer with wait() and notify() method calls on objects. After the Chief make the order, then it's notifyed the WaitPerson to get the order, meanwhile the chief wait to be notified when the meal was delivered to get ready from another meal.

Thanks Mr. De Nijs for your advice! I'm gratefull.
I already purchase one more study guide (Sybex) and i'll use "Complete reference" as a reference when it's the case.

Have a nice day!
Hello ranchers,

I'm addressing to you with all respect,

I need an advice from you about what to study next after Thinking in Java by Bruce Eckel? I mention that i'm an OCAJP8 aspirant  and i already bought whizlabs OCAJP8. So far i studyed Head First Java (read 2 times for perfect image of java in my head), i'm almost there to finish Thinking in Java 4th edition (Read and understand all concept/examples and done all ~400 exercices with corect results) and i don't know what to study next ? Should i study Complete Reference 9th Edition with java 8 inside (recommanded by Whizlabs under a "must do" ) for a deep understanding and after that go to Mala Gupta Study Guide OCAJP8  or go directly to Study Guide OCAJP8 by Mala Gupta ? I really want to take this exam from the first time.
I want to mention that after the study guide i have in mind to practice OCAJP8 test by Whizlabs and OCAJP8 enthuware test.
I really need your advice comming from your proffesional experience but are welcome also any advice from anyone.
I already studyed all the forum with all the materials need for OCAJP8 and i choose those materials mentions in this post because for the moment those are the best accordingly the consistency (if i'll have to buy more/another books i'll do it)

Thanks in advanced!
Thanks a lot Mr. Wong! This help a lot!

Have a nyce day!
I had it a doubt because the executor haven't done yet created all the object in order. After research , I think i have just finded the answer (i readed again and again the concept to see if there was my answer).After printing " ExFunky Constructor id 2 " , i guess that this was the last object putted into hidden que inside executor and he start to run "id 0", and after that he created another object  "id 3" and putted into his hidden que, and after he continue the task for "id 0".. After a closer look at this Executors.newSingleThreadExecutor(), it seems to be recommanded for using with only one runnable object (ex: one runnable object that continuously accept sockets connections, or for logg).
It's that correct?