susana miranda

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

Recent posts by susana miranda

Yes!! what the.. , I had a Arrays class in the same directory a was trying to compile.

I used the qualified package name and it compiles!

Ok! Thanks so much to everybody!
Hi I have the following code:



and when compiling...

%/SCJP/exercises$ javac TestSortCollections.java
TestSortCollections.java:37: cannot find symbol
symbol : method sort(Dog[])
location: class Arrays
Arrays.sort(myDogs);
^
1 error


I can't understand why, I am implementing Comparable and also compareTo, what is the problem with Arrays.sort ?

Thnaks so much.
Yes, my mistake! :S

I tried with:
java TestSplit "15750 7632546 554 5858 648-7428 122%6756" "\d\d\d(-)?(\s)?\d\d\d\d\s"

and I got my result:
# tokens: 4
>15750 <
><
><
>122%6756<

Thaks a lot!

I hope not having this kind of mistakes on the exam.
Hi, I have the following code:



Here is the question, at time execution I get this:
%java TestSplit "15750 7632546 554 5858 648-7428 122%6756" "\d\d\d(-\s)?\d\d\d\d"
# tokens: 2
- 15750
- 554 5858 648-7428 122%6756

I was expecting this:

# tokens: 4
- >15750 <
- > <
- > <
- > 122%6756<

Why does this happen?
Ok Harpreet. Thanks a lot. I had misunderstood * Only one more question:
Why on the second execution returns position start: 15? If my source ends with 90. Is it because null counts or so?

% /SCJP/exercises$ java Regex
Pattern: \d*
Source: 123a456b78ccc90
start: 0 ---group: 123
start: 3 ---group:
start: 4 ---group: 456
start: 7 ---group:
start: 8 ---group: 78
start: 10 ---group:
start: 11 ---group:
start: 12 ---group:
start: 13 ---group: 90
start: 15 ---group:

Hi everybody! this is my first post
and... I have this class



I understand the result of my first execution:

% /SCJP/exercises$ java Regex
Pattern: \d+
Source: 123a456b78ccc0
start: 0 ---group: 123
start: 4 ---group: 456
start: 8 ---group: 78
start: 13 ---group: 0

but not the second

% /SCJP/exercises$ java Regex
Pattern: \d*
Source: 123a456b78ccc90
start: 0 ---group: 123
start: 3 ---group:
start: 4 ---group: 456
start: 7 ---group:
start: 8 ---group: 78
start: 10 ---group:
start: 11 ---group:
start: 12 ---group:
start: 13 ---group: 90
start: 15 ---group:

Why with \d* it returns an empty group if with \d i mean only numbers. I am a little confused :s

Hi Ankit, I saw my mistake. Thanks!
Hello, I have a question. In the following code:

class ThreadC extends Thread{
public static void main(String [] args) {
new ThreadC().metodo1();
}

public synchronized void metodo1()
{
ThreadC b = new ThreadC();
b.start();
// synchronized(b) {
try {
System.out.println("Waiting for b to complete...");
b.wait();
} catch (InterruptedException e) {System.out.println("Error al hacer b.wait()");}
System.out.println("metodo1 terminado");
// }
}

public synchronized void run( ) {
// synchronized(this) {
System.out.println("run into ThreadB");
notify( );
System.out.println("Ya se hizo notify()");
try{
Thread.sleep(2000);
}
catch(InterruptedException e){}
System.out.println("ya se libera el lock de ThreadB");
}
// }
}

At runtime: metodo1 generates IllegalMonitorstateException, as far as I now this is because wait() must be called in a synchronized context.
1. Why isn't enough to make metodo1() synchronized?
2. Why notify() works well in run() method just by making it synchronized?