codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  append character  dulcinea26 at 05:13 on Monday, March 27, 2006
 

hi all;

i have a probelm to append character become a string. for instance:

char first, second, third;
String theword;
for(char r = 'a'; r <= 'z'; r++){
first = r;
for(char s = 'a'; s<='z'; s++){
second = s;
for (char t = 'a'; t <= 'z'; t++){
third = t;
theword = first + second + third;
}
}
}

I want to print 'first + second + third' but i have problem to convert char into string. how actually can i convert char to string or it is possible for me to convert it? does any can give some hints or give me a related website so that can refer to it?

i really appreaciate anyone's help! thanx in advance!

regards;
dulcinea


  Re: append character  taimoorkhan at 07:13 on Monday, March 27, 2006
 

The problem with your code was that the character variables were not initialized. All i did was set each of them to the character 'a'.

You can concatenate characters to strings without a method.

Use "java docs" they are quite helpful when it comes to finding a method that meets your requirements.

public class Concat{

public static void main(String arg[]){


char first='a', second='a', third='a';

String theword;


for(char r = 'a'; r <= 'z'; r++)
first = r;

for(char s = 'a'; s<='z'; s++)
second = s;

for (char t = 'a'; t <= 'z'; t++)
third = t;



theword = ""+first + second + third;
System.out.println(theword);



}

} //end of class


  Re: append character  crwood at 07:39 on Monday, March 27, 2006
 


public class Test
{
public static void main(String[] args)
{
char first, second, third;
String theword;
for(char r = 'a'; r <= 'b'; r++){
first = r;
for(char s = 'a'; s <= 'b'; s++){
second = s;
for (char t = 'a'; t <= 'b'; t++){
third = t;
theword = String.valueOf(first) + second + third;
System.out.println(theword);
}
}
}
}
}


  Re: append character  dulcinea26 at 11:05 on Monday, March 27, 2006
 

thnx.. i really appreciate your help! it works!

thank you very much!

regards;
nurul








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: automatically updating
•  Re: dereferenceing a string to a constant name
•  Re: How can I use javascript to load a image in different size when I click onto it in my thumbnail?
•  Re: Loading Sequence of Frames
•  Re: adding a querystring parameter in a button click event
•  Re: c# .net Exception of type System.StackOverflowException was thrown.
•  Re: onclick thumbnail images in gridview or datalist
•  Re: Plz its urgent:validation code
•  Re: The Dim appExcel As Excel.Application doesn`t work ????


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011