Paweł Baczyński

+ Follow
since Apr 18, 2013
Paweł likes ...
Firefox Browser IntelliJ IDE Java Linux Spring
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
(keep public parts private until JForum day)
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Paweł Baczyński

NumberFormat has the public final String format​(Object obj) method.
How are you parsing 5c to integer? Are you using the method Stephan suggested?
1 week ago
Can you share what is the encoded form that you need to be decoded?
1 week ago
The code is correct. There must be something misconfigured in the IDE.
2 weeks ago

Dave Tolls wrote:Ah.
I did test it, but it's IntelliJ being too clever by half.

It's own launcher allows it to happen.

I just tested it on IntelliJ Community Edition 2017.3 and JDK 1.8.0_152 and I got:

Error: Main method not found in class baczynsp.Hello, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
3 weeks ago
The method is defined as asList(T... a). It is not defined for primitive types.

If you pass int[] into it, the whole array would be treated as the sole element of the created list.
1 month ago

Andy Frels wrote:When importing you import classes and is not a class.

Now it is.

ras oscar wrote:java.lang.Object

I know from process of elimination that the correct import statement is

What do the 3 lines above that refer to? If I instead entered

import java.lang.Object

would I get the desired class?

This is the inheritance tree of class.

It means that: extends extends extends java.lang.Object.

You need to import only these classes that you want to refer to by name.
You don't need to import classes from java.lang package.
1 month ago

Kelly Lykins wrote:I'm pretty sure isn't a real thing. You gotta specify what you are trying to import.

But it is a real thing. It would import a class io from package Java. You would need to make sure such class is available at compile time. And if it doesn't exist you can create it.

Note that Java identifiers are case sensitive. Names and are not the same thing.

As you probably had in mind, writing import; is perfectly legal as far as the language syntax is concerned. The only problem is that the class named doesn't exist.
1 month ago

saurabhmehta mehta wrote:I guess since the other thread has not yet released the lock due to sleep() method.

You guessed correctly. The thread you want to notify needs to own the lock to be notified.

saurabhmehta mehta wrote:So is the notify() call being made only after the entire loop is over?

The call on notifiy() is made several times in the DemoThread. But the call only has an effect on the notified thread when it gets the lock.
Welcome to the Ranch!

You can iterate over map.entrySet() and append key+value to a String (possibly StringBuilder).

Do you care about the order of characters in the output?
If you do, would it be the order of first appearance or alphabetical order? Or any other?

For xxxaddb, do you want to get x3a1d2b1 or a1b1d2x3?
1 month ago
Welcome to the Ranch!

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
This means you are trying to get a character from a String atindex 0 but this index is "out of bounds".
An index is out of bounds if it is negative (not the case here) or >= length of the String.
The only way index 0 can be out of bounds is when a String is empty.

One of the Strings in your example is empty. It is numbers (if you modified it somewhere) or passwordCreated.
1 month ago

Paul Clapham wrote:Since you're doing the same thing in both catch blocks you can simplify that some more:

Nitpick alert!

Actually this code won't compile as FileNotFoundException is a subclass of IOException.
So this can and should be shortened to:
1 month ago
We can't sort a HashMap because HashMaps aren't meant to be sorted.
Complaining about it is kind of like complaining that cars can't fly.
1 month ago