Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

String Add:

Posted on 2006-05-10
8
Medium Priority
?
213 Views
Last Modified: 2010-03-31
hi experts,

Just wired this code not doing proper work:

while (rs_email_address1.next())
{
String EmailAddresses = rs.getString("EMAIL_ADDR");
           if (EmailAddresses != null)
          {
          ToEmailAddress=EmailAddresses+",";
          }
          System.out.println("<br>ToEmailAddress: "+ToEmailAddress);
}

OUTPUT I'm gettingis:
ToEmailAddress: abc@.com,
ToEmailAddress: aec@.com,
ToEmailAddress: acc@.com,

When the actual OUTPUT shoudl be:
ToEmailAddress: abc@.com,
ToEmailAddress: abc@.com,aec@.com,
ToEmailAddress: abc@.com,aec@.com,acc@.com,
0
Comment
Question by:princehyderabad
  • 5
  • 3
8 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 16654910
  ToEmailAddress+=(EmailAddresses+",");
0
 

Author Comment

by:princehyderabad
ID: 16660843
How can we remove last "," ??  its having problem sending emails to: abc@.com,aec@.com,acc@.com,
I want it to be like this: abc@.com,aec@.com,acc@.com (ie no "," at last here)
0
 
LVL 92

Expert Comment

by:objects
ID: 16663328
s = s.substring(0, s.length()-1);
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:princehyderabad
ID: 16663439
How can I check and remove. I mean 1st I like to check if the last letter is "," only then i wanna remove.
0
 

Author Comment

by:princehyderabad
ID: 16663555
Didn't worked ?????

if(s.substring(0, s.length()-1).equals(","))
{
  s = s.substring(0, s.length()-1);
}
0
 
LVL 92

Expert Comment

by:objects
ID: 16663572
> if(s.substring(0, s.length()-1).equals(","))

that should be:

if (s.length()>0)
0
 

Author Comment

by:princehyderabad
ID: 16663587
No, you didnt got my point not checking the length of string. WANT TO MAKE SURE LAST LETTER OF STRING IS COMMA ONLY THEN i WANNA REMOVE LAST LETTER.
0
 

Author Comment

by:princehyderabad
ID: 16663662
Thanks I got it. It was simple ;o)

ToEmailAddress+=(","+EmailAddresses);
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

575 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question