Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1.  public static char[] stringToCharArray(String string) {
  2.         char[] charArrayFromString = new char[string.length()];
  3.         for (int i = 0; i < string.length(); i++) {
  4.             charArrayFromString[i] = string.charAt(i);
  5.         }
  6.         return charArrayFromString;
  7.     }
  8.  
  9.  
  10.   public static char[] removeElement(char[] charArray, int index) {
  11.         char[] reducedArray = new char[charArray.length - 1];
  12.         for (int i = 0; i < index; i++) {
  13.             reducedArray[i] = charArray[i];
  14.         }
  15.         for (int i = 0; i < charArray.length - index - 1; i++) {
  16.             reducedArray[index + i] = charArray[index + 1 + i];
  17.         }
  18.         return reducedArray;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement