|
|
Referring to that article, Listing 1: Q.: "Because Date is mutable, the scheduleTask method must be careful to defensively copy the date parameter (perhaps through clone()) into its internal data structure. Otherwise, task1 and task2 might both execute tomorrow, which is not what was desired. Worse, the internal data structure used by the task scheduler could become corrupt."
A few questions on this:
1) What is 'copying defensively'?
2) What do they mean by 'internal data structure'?
3) How could task1 and task2 execute tomorrow if the code is to be executed today? Then how can new Date() be tomorrow? I don't understand.
4) How would the internal data structure become 'corrupt'? What is 'corrupt' in this context? Containing inconsistent values?
|
|
|
|
|
These questions should be addressed to the writer of that white paper.
Use the best guess
|
|
|
|
|
Hi,
Iam looking for complete example using Spring to get connection pool object(datasource) which is created in websphere server.
I have tried in many ways but no luck facing with different kind of errors.
Thanks in advance for your time.
|
|
|
|
|
Greetings all.
I have a program calculation ip address like this.
public static void main(String[]args){
int host=450;
String sMask="255.255.254.0";
String[] octet;
String IpAddress="192.168.100.0";
octet = IpAddress.split("\\.");
int oct1=Integer.parseInt(octet[0]);
int oct2=Integer.parseInt(octet[1]);
int oct3=Integer.parseInt(octet[2]);
int oct4=Integer.parseInt(octet[3]);
int i;
System.out.println("Ip Address \t \tSubnet Mask");
for(i=oct4;i<host;i++){
System.out.println(oct1+"."+oct2+"."+oct3+"."+i+"\t \t"+sMask);
}
}
print out from this program
Ip Address Subnet Mask
192.168.100.0 255.255.254
192.168.100.1 255.255.254
192.168.100.2 255.255.254
192.168.100.3 255.255.254
until...
192.168.100.449 255.255.254
I want this program,if ip address octet 4 value "192.168.100.255",then continuing this program,like this.
next >
192.168.101.0 255.255.254
192.168.101.1 255.255.254
192.168.101.2 255.255.254
until ...
192.168.101.193 and Finish.
What the lack from my program?
|
|
|
|
|
You need to add some extra code to cater for when i gets above 255. Something like:
for(i=oct4;i<host;i++){
int value = i / 256;
int rem = i % 256;
oct3 += value;
System.out.println(oct1 + "." + oct2 + "." + oct3 + "." + rem + "\t \t" + sMask);
}
Use the best guess
|
|
|
|
|
The code above increments both oct3 and oct4 at the same time, one ahead the other, respectively.
Change:
oct3 += value; to:
oct3 = value; for:
for(i=oct4;i<host;i++){
int value = i / 256;
int rem = i % 256;
oct3 = value;
System.out.println(oct1 + "." + oct2 + "." + oct3 + "." + rem + "\t \t" + sMask);
}
|
|
|
|
|
Actually we were both wrong; it should be:
value += oct3;
System.out.println(oct1 + "." + oct2 + "." + value + "." + rem + "\t \t" + sMask);
Use the best guess
|
|
|
|
|
good call.
|
|
|
|
|
Hi,
We have a requirement to capture a signature on the tablet in 3 byte ASCII format and then base64 encoding on it. Maximum characters allowed is 1024 only.The requirement is for browser based thin client
Thanks
|
|
|
|
|
when i run my web project with tomcat(stat as a NT service),if the service start with system users ,the project won't run properly,
however,when the service log on with administrator(current user),the project run successfully.why ?
|
|
|
|
|
Because the local system account has different permissions and environment than the user.
There are many possible reasons why it might fail.
And if you check your resources before using and log errors it would probably tell you exactly what those are.
|
|
|
|
|
I have checked the tomcat log, and the problem has been solved .
thank you~ ^-^
|
|
|
|
|
Hi!! I'm trying to understand the sharpen your pencil Class Puzzle4 from head first java.. But the math and the logic is confusing me... I hope someone can give me some explanation before I move on in the book... The output of the code should be Result 543345
public class Puzzle4 {
public static void main (String[] args){
Puzzle4b[] obs = new Puzzle4b[6];
int y = 1;
int x = 0;
int result = 0;
while (x < 6){
obs[x] = new Puzzle4b();
obs[x].ivar = y;
System.out.println("obs[x] = " + obs[x].ivar);
y = y * 10;
System.out.println(" Y = " + y);
x = x + 1;
System.out.println(" x = " + x);
}
x = 6;
System.out.println(" x = " + x);
while (x > 0){
x = x - 1;
System.out.println(" x = " + x);
System.out.println("obs[x].doStuff(x) = " + obs[x].doStuff(x));
result = result + obs[x].doStuff(x);
}
System.out.println("Result " + result);
}
}
class Puzzle4b {
int ivar;
public int doStuff(int factor){
if (ivar > 100){
System.out.println("ivar = " + ivar);
return ivar * factor;
}
else{
return ivar * ( 5 - factor );
}
}
}
What isreturn ivar * ( 5 - factor );????
ivar is an instance and the value of it is unique to every object is that right?? The logic of the method is confusing me. I understand that x is the argument to
modified 15-Jul-13 17:27pm.
|
|
|
|
|
ivar is an integer variable whose value is set for every new instance of the Puzzle4b class. However, without a lot more information it's anyone's guess what its purpose is or what this project is about. I suggest you go back to wherever you found this code and ask the person who wrote it.
Use the best guess
|
|
|
|
|
obs[5]= 100000>100 true. 100000*5= 500000
obs[4]= 10000 >100 True. 10000*4= 40000
obs[3]= 1000 > 100 true. 1000*3= 3000
obs[2]= 100>100 False. 100*(5-2)= 300
obs[1]= 10>100 False. 10*(5-1)= 40
obs[0]= 1>100 False. 1*5= 5
Add them all up you get 543345
|
|
|
|
|
Fascinating! And what is that supposed to mean?
Use the best guess
|
|
|
|
|
Did you really read the code dude?
The output is 543345 observe that the object obs[x] is an array that means obs[x]= {1,10,100,1000,10000,100000}
obs[5]= 100000>100 true. 100000*5= 500000
obs[4]= 10000 >100 True. 10000*4= 40000
obs[3]= 1000 > 100 true. 1000*3= 3000
obs[2]= 100>100 False. 100*(5-2)= 300
obs[1]= 10>100 False. 10*(5-1)= 40
obs[0]= 1>100 False. 1*5= 5
add them and you will get the 543345.. I understand the logic now how come you still don't and you were trying to help me?
|
|
|
|
|
|
Skykitten,
First of all, you would do well in life not to antagonize someone whom is trying to help you. Not cool.
Second, you act like the code was so easy for someone out-of-context to understand and you can't get the jist of it? If it is so simple why are you here asking what it is?
Let's take a look at your code:
while (x < 6){
obs[x] = new Puzzle4b();
obs[x].ivar = y;
System.out.println("obs[x] = " + obs[x].ivar);
y = y * 10;
System.out.println(" Y = " + y);
x = x + 1;
System.out.println(" x = " + x);
}
This particular part initializes 6 instances of the Puzzle4b class and assigns them to parts of an array(obs[x]). with each increment(loop), y(which is used to initialize the ivar integer here) is incremented by multiples of 10. so for each instance created: 1, 10, 100, 1000...etc. this ivar is for the calculation done here:
public int doStuff(int factor){
if (ivar > 100){
System.out.println("ivar = " + ivar);
return ivar * factor;
}
else{
return ivar * ( 5 - factor );
}
when this method is called(horrible name by the way, dostuff? really?) it is called upon each instance, which causes the calculations to be unique to each instance. ie obs[1]'s ivar = 10, so 10 is used when I call the dostuff method on that particular instance. so on and so forth. The factor variable is nothing more than the name assigned to the variable passed to the method so that it can do the calculation and send it back to your main thread for printing.
at this point, since you were being a bit brash, i digress. Figure the rest out by RTFM.
Good day.
|
|
|
|
|
I don't think this reply was meant for me.
Use the best guess
|
|
|
|
|
You are correct. it was for skytten.
|
|
|
|
|
When Installling application on a clients machine which of the Connection string will work?
1.
String conUrl = "jdbc:sqlserver://localhost:1433; databaseName=paytest; user=sa; password=; integratedSecurity=true;";
2.
String conUrl = "jdbc:sqlserver://localhost:1433; databaseName=paytest; user=mypc; password=; integratedSecurity=true;";
|
|
|
|
|
Depends whether your client has a SQL server running at port 1433, his firewall doesn't play games with your app and quietly allows the connection and the username and password is valid.
So, the bottom line:
Unable to predict.
Good Luck!
Beauty cannot be defined by abscissas and ordinates; neither are circles and ellipses created by their geometrical formulas.
Source
|
|
|
|
|
What happens when you try it?
Use the best guess
|
|
|
|