Paweł Baczyński

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

Recent posts by Paweł Baczyński

What is a type of statusdataframe.col("Status")?
Something bad must be happening with its internals.

An empty list wouldn't cause toArray() to throw NoSuchElementException.
An empty String in the list would result in StringIndexOutOfBoundsException.
A null reference inside the list would result in NullPointerException.
A non-String object in the list would result in ClassCastException.

I can't think of any other condition that could result in an exception except the list does something weird.

By the way, when you sort this issue out you may find that System.out.println(ints); doesn't print what you expect.
11 months ago
Hello Scott and Jeanne

Does your book mention the upgrade exam (1Z0-817)?

EDIT: I am answering my own question... Yes, the book even says that on its cover.  
The best part of doing the beta is the price.
The wors part is not knowing if you passed for some time.
From javadoc:

javadoc wrote:Returns:
   true if the named file does not exist and was successfully created; false if the named file already exists


And the method does throw exceptions:

javadoc wrote:Throws:
   IOException - If an I/O error occurred
   SecurityException - If a security manager exists and its SecurityManager.checkWrite(java.lang.String) method denies write access to the file

1 year ago
Java 14 release is scheduled for general availability on March 17, 2020. It introduces three changes to the language and one useful feature for runtime.

Read more about it at: https://solidstudio.io/blog/java-14-new-features.html

Mike Savvy wrote:I mean something like this:



This can be emulated using method overloading.

This prints:
short
short
int


Note that selecion of a method to call happens on compile time.
1 year ago
You can pass an instance of an object implementing some interface (Function, UnaryOperator).
1 year ago

Campbell Ritchie wrote:Remembering that n % 2 == 1 doesn't reliably find odd numbers.


Forget the 1. Compare to 0. You'll get n % 2 != 0 that reliably finds odd numbers.
1 year ago
Also, don't write

Instead write
2 years ago

Piet Souris wrote:then b.m1() is illegal.


If you program to the interface, you won't need an instance method called m1() as such method is not defined in the interface.

Similarly, when you program to interfaces with lists like List<String> list = new ArrayList<>(); you don't expect to be able to call list.ensureCapacity(123);.
2 years ago

Dave Tolls wrote:Indeed, looking at the Arrays source code and it does use its own private class.



And the private class is named ArrayList.

But it isn't java.util.ArrayList. It is java.util.Arrays.ArrayList.

2 years ago
It would help if you shared what you don't get.
2 years ago
It is, however, possible to "leak" the instance into other thread before final variable is assigned.

Be warned. This code is obscure.
It shows why you shouldn't "leak" the this from a constructor and why you shouldn't start threads inside a constructor.



It prints:
[The value is: null]
[The value is: value]

What doubts do you have? You didn't ask any question.

Also, please use code tags.
2 years ago