Created
April 23, 2012 09:11
-
-
Save shime/2469746 to your computer and use it in GitHub Desktop.
replace every character at odd index with "&" in a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Nes | |
{ | |
public static void main(String[] args) { | |
String a = "lastavice trče"; | |
for (int i=0; i < a.length(); i++){ | |
if (i % 2 != 0){ | |
a = a.substring(0,i-1) + "&" + a.substring(i, a.length()); | |
} | |
} | |
System.out.println(a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment