Skip to content

Instantly share code, notes, and snippets.

@thenaveensaggam
Created September 30, 2019 04:47
Show Gist options
  • Save thenaveensaggam/7196c5622a7f3e60d2c494b3ddc3ceb6 to your computer and use it in GitHub Desktop.
Save thenaveensaggam/7196c5622a7f3e60d2c494b3ddc3ceb6 to your computer and use it in GitHub Desktop.
public String everyNth(String str, int n) {
String temp = str.substring(0,1);
for(int i = n ; i<str.length(); i += n) {
temp += str.charAt(i);
}
return temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment