Paweł Baczyński

Bartender
+ Follow
since Apr 18, 2013
Paweł likes ...
Firefox Browser IntelliJ IDE Java Linux Spring
Kraków
Cows and Likes
Cows
Total received
46
In last 30 days
0
Total given
60
Likes
Total received
488
Received in last 30 days
4
Total given
641
Given in last 30 days
12
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paweł Baczyński

My suggestion is that there are zero lines <searchTag> in the file. You are using equals so any single white space will cause your filter condition to return false.

Note that you don't have to read the whole file to the list and then create a stream from the list.
You may create a list from the file directly by using Files.lines().
5 days ago
Of course it is.
If thread a calls b.join() and thread b calls a.join() they will both wait for each other.

There is even simpler case. Try calling Thread.currentThread().join() and see what happens.
Welcome to the Ranch!

You will find the answer here: https://coderanch.com/wiki/659740/create-Java-program
1 week ago
Welcome to the Ranch!

What question do you have? What do you need to be explained?
1 week ago
How are you compiling the classes (what command)? How are you running them? What is the directory you compile/run them from? (type cd in the console).
1 week ago

jose laguia wrote:your wrote

Line 3 prints true because runtimeException is an instance of class Exception.....


And then I wrote (...) or a subclass of Exception.

You wrote:This is technically correct (the best kind of correct ).

But, your confusion with the super-/subclass comes from the fact that you wrote the relation between classes inversely.
Write this as below and everything should be clear:


jose laguia wrote:Maybe you are confusing variables with objects.


I am not. When I wrote  runtimeException is an instance of class Exception what I meant was an object referenced by the variable named runtimeException is an instance of class Exception.
The book is correct.

Take a look at this code:
Line 3 prints true because runtimeException is an instance of class Exception or a subclass of Exception (in this case, the RuntimeException class).

If what you proposed were true, it would be the line 4 that prints true, as object is an instance of Exception or a superclass of Exception (in this case, the Object class)..
Your swap method does not work as you think.

In Java arguments are passed by value. It means that you can't change contents of an array like this.
To swap elements of an array you would need to pass an array and indexes of values to be swapped.
3 weeks ago
Welcome!

Campbell Ritchie wrote:It's a really good book because you had such good technical editing



And I couldn't agree more.
Maybe the value is a String "null"?
2 months ago
Are you sure that Java 10 is configured?

I can see C:\Program Files (x86)\Java\jdk1.0.0_144 on the screenshot.

Also, please post text not screenshots.

I tried your code on JDK8 and it compiled just fine.
2 months ago
You can read Effective Java Item 1: Consider static factory methods instead of constructors.
2 months ago