Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. public class Test{
  2. public static void main(String[] args){
  3. String guess = "Colin is so great!";
  4. System.out.println(guess);
  5. guess = setCharAt(guess,1,'c');
  6. guess = setCharAt(guess,8,'X');
  7. System.out.print(guess);
  8. }
  9. public static String setCharAt(String s, int i, char c){
  10. return s.substring(0,i) + c + s.substring(i+1);
  11. }
  12. }
  13.  
  14.  
  15. makes output:
  16.  
  17. Colin is so great!
  18. Cclin isXso great!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement