0

Hey can someone help me with my java program
you have to A-Z to Z-A

here s what i ve done so far:

class az
{
public static void main(String[]args)throws Exception
{
String x="abcdefghijklmnopqrstuvwxyz";
int ctr;
for(ctr=1;ctr<=26;ctr++)
{
char z=x.charAt(26);
System.out.print(z);
}
}
}

Edited by kris222: silly mistake

3
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by stultuske
Featured Replies
  • [QUOTE=kris222;1770118]Hey can someone help me with my java program you have to A-Z to Z-A here s what i ve done so far: class az { public static void main(String[]args)throws Exception { String x="abcdefghijklmnopqrstuvwxyz"; int ctr; for(ctr=1;ctr<=26;ctr++) { char z=x.charAt(26); System.out.print(z); } } }[/QUOTE] Hmm why not just:[code] String x … Read More

0

what exactly do you want? to reverse the String?
if you want to keep it like this, you'll have to create a String (say, y = "";)
and say:
y+= x.charAt(x.length() - ctr);

and yes, I just briefly looked over your code, there might be a conflict with your counters, but this is just to point you in the direction, not to finish it up :)

1

Hey can someone help me with my java program
you have to A-Z to Z-A

here s what i ve done so far:

class az
{
public static void main(String[]args)throws Exception
{
String x="abcdefghijklmnopqrstuvwxyz";
int ctr;
for(ctr=1;ctr<=26;ctr++)
{
char z=x.charAt(26);
System.out.print(z);
}
}
}

Hmm why not just:

String x = "abcdefghijklmnopqrstuvwxyz";
            for (int ctr = 25; ctr >=0; ctr--) {
                char z = x.charAt(ctr);
                System.out.print(z);
            }

Edited by DavidKroukamp: n/a

0

because that wouldn't help if you need to use the inverted String later on, but don't know if that's the idea.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.