• Post Reply Bookmark Topic Watch Topic
  • New Topic

difficulty in debugging  RSS feed

 
gayathriy Nandakumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..i am trying to swap a string with the randomly generated index here..plz help me in debugging..


public class stringarray
{
public static void main(String [] args)
{
StringBuffer codestring=new StringBuffer("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
for(int i=0;i<codestring.length();i++)
{

int r=(int)(Math.random()*43);

char temp=(codestring.charAt(i));
codestring.charAt(i)=codestring.charAt(r);
codestring.charAt(r)=temp;
System.out.println(codestring);

}}
}
 
Mike Noel
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please put your code in code tags, it makes it easier to view. What problem are you seeing?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that charAt is a method that produces a char value.

Can you place a method call on the left-hand side of an assignment statement?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!