473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to replicate a string value.?

consider the following code

String a="";
for(int i=1;i<4;i++){
a="--" ;
}

i want the value of a as follows
if i=1
a="-";
if i=2
a="--";
if i=3
a="---";
and so on.
i need the final value of 'a' . im appending the value of 'a' along with another string and putting it in a hashmap.
eg, hashmap h=new hashmap; h.put("name",a+"shini");
the result should be -shini in 1st case
,
--shini in 2nd case
---shini in 3rd case
how do i do this
Mar 1 '07 #1
3 6683
DeMan
1,806 1GB
Look up the API entry for string....if you can't do
String + char (which you may not be able to), there should be a method for "append" or "cat" (but I have a suspicion "this is " + "my String" will create 1 string "this is my String")
Mar 1 '07 #2
r035198x
13,262 8TB
consider the following code

String a="";
for(int i=1;i<4;i++){
a="--" ;
}

i want the value of a as follows
if i=1
a="-";
if i=2
a="--";
if i=3
a="---";
and so on.
i need the final value of 'a' . im appending the value of 'a' along with another string and putting it in a hashmap.
eg, hashmap h=new hashmap; h.put("name",a+"shini");
the result should be -shini in 1st case
,
--shini in 2nd case
---shini in 3rd case
how do i do this
Just modify your for to


Expand|Select|Wrap|Line Numbers
  1.  for(int j=0;j<i;j++){
  2. a= a + "-" ;
  3.  
After that you can then do
a = a + "shini";
and you are done.
Mar 1 '07 #3
Just modify your for to


Expand|Select|Wrap|Line Numbers
  1.  for(int j=0;j<i;j++){
  2. a= a + "-" ;
  3.  
After that you can then do
a = a + "shini";
and you are done.
Thank You

I got the answer...
Mar 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Glynn Johnson | last post by:
I understand that there is no way to upload multiple files using ASP and COM+ without having multiple form elements like <input type='file'>. I also understand that there is no way to...
3
by: jaekim | last post by:
Hi. I am wondering if it is a good idea to replicate sql server db files using frs. I don't really know how the frs works, so does frs replicates the whole database from time to time or just...
1
by: Robert Scheer | last post by:
Hi. I have a form with some textboxes in it. When a user clicks a button, I need to verify if only one of the textboxes if filled and if so, I need to replicate the value of this textbox to all...
2
by: db2group88 | last post by:
we are using db2 udb v8.2 Express edition on windows 2003,we use third party vendor software to help replicate one server to another. Production server has three instances, each instances has one...
6
by: Stanley Sinclair | last post by:
Can I "replicate" from a flat file which changes, but is not a part of a formal database?
0
by: Paul Hobbs | last post by:
Hi All, I am trying to replicate the functionality of the HTML FileField control. I can use it just fine to prompt a user to browse to a file, and it retrieves the full path just fine. I can...
0
by: Paul Hobbs | last post by:
Hi All, I am trying to replicate the functionality of the HTML FileField control. I can use it just fine to prompt a user to browse to a file, and it retrieves the full path just fine. I can...
6
by: Michael.Suarez | last post by:
Consider the TextBox Control. It has a KeyPress event of type KeyPressEventHandler which passes a KeyPressEventArgs to whatever method is assigned to the event. When you set e.Handled = false...
1
by: mg | last post by:
Is there a way to replicate the GAC on a win2003 server to another similar server? We are currently using DFS to replicate files, and I do not see how to use DFS to replicate the GAC. -- mg...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.