Tuesday, January 21, 2020

Java Arrays

Copy Elements of Array into new Array :

Arrays.copyOfRange(sourceArray, i, i+3)

This will copy 3 elements from the location i into new Arrays

Character Arrays :

Remove punctuation from String :

1) Convert String into char Array

char[] charArr = str.toCharArray()

StringBuilder sbr = new StringBuilder();

for(i=0;i
if(charArr[i].isLetterOrDigit()) {

            sbr.append(charArr[i])

}

}

sbr.toString() // will print this will all punctuation removed.