Sathya Narayanan Natarajan

Greenhorn
+ Follow
since Mar 15, 2005
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 Sathya Narayanan Natarajan

Hi

From the String[] Array, Construct a Comma-Separated String Of Names in the following format ,

'Name1','Name2','Name3'

The following code will help you get a Comma-Separated-String of Names

String param = stringArray[0];
for (int i = 1; i<stringArray.length; i++) {
param += stringArray[i];
}


Then, just set the param in the statement as follows,

preparedStatement.setString(1,param);
Then run the query.

Hope this helps you,
Thanks.
Sathya
Hi,
This is one of the advantages of the Compound Assignment Operator +=

When you do any integer arithmetic with byte values, the compiler expects you to put an explicit cast before assigning the result to a byte variable.

For example,
byte a = 3;
a = a + 5; //won't compile,
//needs an explicit cast a = (byte) a + 5;

But when you do the same thing with Compound Assignment operator,We are ensuring the Compiler that the resulting value will definitely fit to a byte variable.
See this,
byte a = 3;
a += 5; //Compiles without any error.

Hope this answers your question.
Thanks,
Sathya.


19 years ago