DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2006
    Posts
    8

    append character

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    Use theword = first +""+ second +""+ third;
    doing first+second the compiler interprets the characters as chars and thus as numbers. adding an empty string will cast the chars to a string.
    by the way: for loops with characters are not that nice. use something like that:
    Code:
    final String chars = "abcdefghijklm...";
    for (int i=0; i<chars.length; i++){
      char anychar = chars.charAt(i);
    }

Similar Threads

  1. Replies: 1
    Last Post: 09-17-2008, 03:19 AM
  2. Microsoft's C++ bigotry
    By Phil Weber in forum .NET
    Replies: 632
    Last Post: 10-01-2003, 12:00 AM
  3. Replies: 2
    Last Post: 06-21-2001, 04:58 AM
  4. Append Queries?
    By Bryan in forum VB Classic
    Replies: 3
    Last Post: 07-14-2000, 09:44 AM
  5. Append Queries?
    By Bryan in forum VB Classic
    Replies: 1
    Last Post: 06-28-2000, 12:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links