this should be the output:
A b C d E f G h I j K l M n O p Q r S t U v W x Y z

heres what i ve done so far:

class za
{
public static void main(String[]args)
{
String x="abcdefghijklmnopqrstuvwxyz";
int ctr;
for(ctr=1;ctr<=x.length()-1;ctr++)
{
if(ctr%2)
System.out.print(Character.toUpperCase(x.charAt(ctr)));
}
}
}

Recommended Answers

All 3 Replies

if you want to find a particular character and then replace a particular position first you should convert the string to char array then iterate over the character array and change the character you want to

here is modified code

class za
{
public static void main(String[]args)
{
String x="abcdefghijklmnopqrstuvwxyz";
int ctr;
for(ctr=0;ctr<=x.length()-1;ctr++)
{
if(ctr%2==1)
System.out.print(x.charAt(ctr)+" ");
else
System.out.print(Character.toUpperCase(x.charAt(ctr))+" ");
}
}
}
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.