HungryJavaGoat

Greenhorn
+ Follow
since Jun 30, 2006
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 HungryJavaGoat

But the question says that hashcode and equals method have been implemented appropriately. So "implementing the hashCode in wrong way" scenario is not applicable here.
Can a Value object (Transfer object pattern) and persistance object have "USING" relationship ?

That is ValueObject's overloaded constructor will take persistance object as parameter and get the details of persistance object and set the details to its member variables.

My question here is , is it a correct design ? or shoud i use any static method in ValueObject to give a instance of valueobject with the details or an external method (out of value object ) which will create a value object with details from persistance object.

Thanks in Advance
do J2EE 1.3 supports Asynchronous Bean ? If so where can i get the details from ? Thanks in Advance ..
Hi ,
Thanks for your suggestion ..

but he can also enter a number without decimal which is a valid one.
example:
##.##
following are valid:
1
11
11.0
11.02
.0
.01
11.11


Following are invalid
111.00 (exceeds the number of digits before decimal)
11. (invalid if "." is present then there should be atleast one digit followed by that)
11.001 (Invalid. exceeds .number of digits after decimal point)

i want to make one regular expression which will match all the conditions to tell me whether the double entered is valid double and its matching my constraints. Thanks in advance.
Hi,
How can we validate a double value with regular expression in java?
For example ..if a field takes ###.### as mask ..
then user can enter atmost 3 digits before the decimal and one decimal point followed by atmost 3 digits.
thanks for the guidance in advance..
Hi,
How can we validate a double value with regular expression in java?
For example ..if a field takes ###.### as mask ..
then user can enter atmost 3 digits before the decimal and one decimal point followed by atmost 3 digits.
thanks for the guidance in advance..
16 years ago
Yeah..thats right .. thinking to do that in controller layer before making call to facade layer (EJBs). Thanks
16 years ago
JSP
Hi,
I am displaying a profile data in browser window after executing a JSP. There is a button called Close . When the user clicks the close button.. if the user has made some changes.. then i need to save that data to DB othewise i shouldn't . How can we check that ? .

in javascript we can do one to one checking for each form elements ?
16 years ago
JSP
In that case can we say that static variables and static methods are inherited ??
Hi,
Can we access super class's static variable in subclass without using Superclass name or reference.
what would be the output of the following program
Hi ,
I am also preparing for SCJP1.5 . Reasons are

1. Its new ..and i can learn new features and the way to use it.
2. Challenging too ...


But i have a doubt.. If Java 6.0 (Mustang) is already in beta stage... Will the Industry directly migrate to java 6.0 rather than going for java 5 and again to java 6 ??
Yeah .. you are right. i just did for an example ... to show that it depends on the runnable object(whether it implements Runnable or extends thread in which later is case not needed as you said) you are sending as input for thread.
try the following program ...

public class ThreadTestFinal{
public static void main (String[] args){
Runner r = new Runner(5);
Strider s = new Strider(5);
Thread t1 = new Thread(r, "Thread A");
Thread t2 = new Thread(r, "Thread B");
Thread s1 = new Thread(s, "Thread C");
Thread s2 = new Thread(s, "Thread D");
t1.start();
t2.start();
s1.start();
s2.start();
}
}

class Runner implements Runnable {
private int counter;
private final int MAX_LIMIT;
Runner(int limit) {
MAX_LIMIT = limit;
}

public void run() {
try {
for (int i=0; i<MAX_LIMIT; i++) {
System.out.println(Thread.currentThread().getName() + ": " + counter++);
Thread.sleep(1000);
}
} catch(InterruptedException e) {
e.printStackTrace();
}

}
}


class Strider extends Thread {
private int counter;
private final int MAX_LIMIT;

Strider(int limit) {
MAX_LIMIT = limit;
}
Strider(int limit, String name) {
MAX_LIMIT = limit;
setName(name);
}

public void run() {
try {
for (int i=0; i<MAX_LIMIT; i++) {
System.out.println(Thread.currentThread().getName() + ": " + counter++);
Thread.sleep(1000);
}
} catch(InterruptedException e) {
e.printStackTrace();
}
}
}


the thing is Thread class intern implements Runnable and thus it can also be treated like a Runnable (many threads CAN share the same object instance.. as you said. ).

pls correct me if i am wrong.
Hi ,
The o/p is 12,12

Explanation:
Even though i is declared as private , since both the method main and class Inner belongs to the class Test ... main can access private member of class Inner.


if the following code is in another class then..i will not compile

TestInner test = new TestInner();
TestInner.inner.i++;
System.out.println(TestInner.inner.i + "," + test.inner.i);


you can try compiling following program and see the output :


public class TestInner {

public static void main(String[] args) {
TestInner test = new TestInner();
TestInner.inner.i++;
System.out.println(TestInner.inner.i + "," + test.inner.i);
}

static class Inner {
private int i = 11;
}

static Inner inner = new Inner();

}


class InnerAccessor {

public InnerAccessor() {
TestInner test = new TestInner();
TestInner.inner.i++;
System.out.println(TestInner.inner.i + "," + test.inner.i);
}

}


it will not compile ...
YES..its a subclass of Foo. only difference is it is defined inside the argument.