Maria Kowalczyk

Greenhorn
+ Follow
since Jul 03, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Maria Kowalczyk



This code prints long.
Why is that? How did compiler decided that it likes long version of foo() method the most.
If I had to guess I'd pick int... or possibly Integer as they are most similiar to what was passed.
But why long?
10 years ago
Hello. I saw code like this.

I can understand that it is a HashSet with one element "Hello" in it.
I don't understand this syntax. Why there are double curly braces?
10 years ago
Or you could just make displayArray() method static.
10 years ago
So it should have run with no firewall and with rmiregistry started?
So there is something wrong with my computer?
Does my code run on your machine?
10 years ago

Swastik Dey wrote:Did you start rmiregistry?


Yes, I did.

Tony Docherty wrote:Is the IP address correct, is there a firewall? Have you tried to ping from one machine to the other?


What IP address? I didn't type any address at all. I haven't even started to write any client code. I thought I first get the server running before I try to write a client. I posted all code I've got till now.
There is no firewall. I turned one off. I can't ping one machine to the other as there is no other machine yet.
10 years ago
Hello Ranchers!
I have one issue with RMI (yeah, I am learning RMI now...).

There is my remote interface There is an implementation:
And here I try to launch it:
Unfortunately I get an exception that I do not understand.
Here it is:

Why is it refusing connections? I did rmic WorkerImpl and it generated WorkerImpl_Stub.class file.

I looked for a code to run RMI here.
10 years ago
Thanks . Buziak :*
10 years ago
I have a problem with my format method. It is Locale-depentent (as DecimalFormat uses machine's default locale).
I tried to found a solution for that that allows me to use the same output but with fixed Locale.US (or any other locale I might want to pass ).
I found that NumberFormat class takes a Locale as an argument in its factory methods but I haven't found a method that takes a String pattern.
I'm stuck. I want a Locale setting from NumberFormat and also String-pattern setting from DecimalFormat.
Can you help me?
10 years ago
Why the code below doesn't work? I want to add a set to itself (just experimenting with Java). I declare a Set that holds any class that implements Set interface (by writing ? extends Set).



It won't compile giving:
java: no suitable method found for add(java.util.Set<capture#1 of ? extends java.util.Set>)
method java.util.Set.add(capture#2 of ? extends java.util.Set) is not applicable
(actual argument java.util.Set<capture#1 of ? extends java.util.Set> cannot be converted to capture#2 of ? extends java.util.Set by method invocation conversion)
10 years ago

Winston Gutkowski wrote:Great. Now that you have worked it out, FYI: a slightly simpler way with your original loop would simply be:I'll leave you to work out why.

That's also a good idea . But it won't work in my case (in the real code) as my function does some stuff after the loop.

fred rosenberger wrote:your original post has:

a simplified example of your code
What you want it to do
What it really does
What you expect it to do.

That's pretty much a perfect post of how questions should be asked.


Well, I've read HowToAskQuestionsOnJavaRanch .

fred rosenberger wrote:Have a cow!!!


Thanks!!! Buziak for you too :*
10 years ago
I did it

I introduced a variable to control the loop. And you saying it breaks out of the switch statement helped me with aother issue .
Thanks for help . Buziak :*
10 years ago
Hallo Ranchers!
I have a problem with a program I write.
I'll post simplified example.I don't know what I am doing wrong. The program is supposed to take a line from user and compare it against case statements in swicth.
If it matches it should print appropiate text and ask again, and if not the program should exit (printing a message)

The output I get:

Enter a number: 1
one
two
Enter a number: 2
two
Enter a number: 3
Enter a number: 3
Enter a number: Exception in thread "main"


The exception message happens when I press Ctrl + C to exit the program.

The output I want:

Enter a number: 1
one
Enter a number: 2
two
Enter a number: 3
Exiting...


So, any help please
10 years ago
Hi!
I were looking at the Color class here and I wonder why static fields are doubled.
Like yellow and YELLOW etc...
10 years ago
SO I need to save new String to s

I did it

10 years ago
Hello
This morning I decided to learn Java . So here I am ;).
I have one problem with String.
Take a look:



The output is:
[ Hello there ]
[Hello there]
[ Hello there ]


I'm sure I'm doing something wrong . Can you tell me what? I would apreciate a link to some good tutorial that explains Strings .
10 years ago