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);
}
}
}

Recommended Answers

All 3 Replies

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);
            }

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.