Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Method editing strings of an Array List

Reply
Thread Tools

Method editing strings of an Array List

 
 
gagirl1105 gagirl1105 is offline
Junior Member
Join Date: Mar 2012
Posts: 2
 
      03-20-2012
Hi, all! I'm working on an introductory Java assignment and am slightly confused on an Array List issue. Our assignment involves going through each String element of an Array list and changing every 'e' to a '-'. I've run into an issue in that I can cycle through the Strings but can't go through each character within that string. I've tried to set up two different for-loops but am now having issues setting a limit to the for-loop because the length I'm limiting it to is an integer. Any help would be appreciated. Here's what I have so far:
Code:
if(args.length <=10)
  {
       for (int i = 0; i < args.length; i++)
 
       {   
          String iString = Integer.toString(i); 
 
 
           for (int j = 0; j < iString.length; j++)
           {
           char ch  = args[i].charAt(j);                    
           if(ch == 'e')
               {   String minus = "-";
                    newString += minus;
               }
             else
             {
                   newString += Character.toString(ch);
              }
 
        }
 
    }
   args[i] = newString;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory issues when storing as List of Strings vs List of List OW Ghim Siong Python 2 11-30-2010 12:22 PM
Are you looking for high quality photo editing and video editing? gwanglu@gmail.com C Programming 0 07-19-2006 12:32 PM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
How to generate k+1 length strings from a list of k length strings? Girish Sahani Python 17 06-09-2006 11:01 AM
convert list of strings to set of regexes; convert list of strings to trie Klaus Neuner Python 7 07-26-2004 07:25 AM



Advertisments