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 4 Years Ago by kris222: silly mistake

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 :)

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 4 Years Ago by DavidKroukamp: n/a

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.