This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!

Campbell Ritchie

Marshal
+ Follow
since Oct 13, 2005
Cows and Likes
Cows
Total received
203
In last 30 days
10
Total given
396
Likes
Total received
5692
Received in last 30 days
117
Total given
232
Given in last 30 days
16
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Campbell Ritchie

I think you don't use Optional at all.
You make sure the Employee reference doesn't point to null. Wherever you are initialising the employee variable, you make sure it isn't null. If you initialise it in the Foo() constructor, you do something like this:-If you go through the Objects class, you will find a much simpler way to do the same thing.
Now the null pointer exception is no longer a notification to yourself of a programming problem, but a warning to the users that they have breached the preconditions of that constructor/method.
Note that I have omitted taking a defensive copy from that example.

If you used Optional at all, you would end up with this sort of code:-The problem with an Optional is that you are hiding the null, and you have to write code to cope with it when you try to use that field. I think that you are in a context where nulls ought to be banned. Ban them early.
9 hours ago
Don't set ordinary components visible; it is only necessary to call setVisible() on your top level container.
If you are calling setText() on your text area, the most recent text from the result set will be what it displays. Find out whether you can use an append() method or similar.

Discussion now in our GUIs forum.
9 hours ago

Yedija Tjin wrote:Thank you

That's a pleasure

. . .  2. I install mix version jdk version 8 and 11 somehow it didn't work, so what I did was I uninstall everything and just install jdk ver 11 . . .

Since you haven't shown us your PATH, we don't know that you have set it correctly. It might have been possible to correct your problem by editing the PATH, so, as Daniel Desmaecker said, you can install multiple different Java® versions.
10 hours ago
Why would you expect two different languages to have the same syntax?
10 hours ago
Good to see you here Welcome

I hope you have lots of interesting questions about the book.
22 hours ago

Daniel Demesmaecker wrote:. . . classpath variable, I know what it does . . .

It completely messes up your programming by making it impossible to find the requisite files, that is what it does

Unfortunately there are still old books around telling you to set a system CLASSPATH, so we need to know what the user has done.
22 hours ago
We only delete posts if there is something seriously wrong with them.
23 hours ago
Whoever said you have set up your environment variables wrongly is, I am sure, correct.
Please atart by showing us your variables: please show us what happens when you pass the following three instructions to the command line:-

when I run C:\Java\src>java MooseGreetings.java

it created MooseGreetings.class

No, it didn't; in order to create XXX.class you have to use the javac command.

Once we know what your environment variables are set to, we can help you correct the problem.

Why have you got a java directory inside the root of C? I usually suggest you create a java directory inside your User\XXX folder:-You only need line 1 once per computer, then use line 2 to navigate to that directory whenever you open the command prompt.
23 hours ago
First things first:

Welcome to the Ranch
23 hours ago
Moved to our Android forum.
1 day ago
You will have to provide more details. What are you searching for? What sort of data structure are you searching in? What search techniques are you going to use?
1 day ago
dj raman,
I have merged your topic into this topic. I hope that helps.
1 day ago
I merged your stuff with the following thread. I hope that is okay by you.
1 day ago