Out of the box:
Character.isAlphabetic('a')
Character.isDigit('a')
Character.isLetter('a')
Custom code:
char c = ''
if (c>='a'&& c<='z') || (c>='A' && c<'Z') || c>='0' && c<='9'){
return true;
}
============================================
Out of the box:
new String(strChars);
Custom code:
String fa="";
for(int i;i<ca.length;i++){
fa+=ca[i];
}
============================================
Out of the box:
Arrays.sort(arr);
Custom code: Bubble sort On2
for(int j=0;j<a.length;j++){
for(int i;i<a.length-j-1;i++){
if(a[i]>a[i+1]){
int swap = a[i];
a[i] = a[i+1];
a[i+1] = swap;
}
}
}
============================================
Out of the box: (in datatype is Integer and not int)
Integer[] arr = new Integer[] {2,3,4,5,3,3}
List<Integer> int = Arrays.asList(arr);
Custom Code:
char[] ca = s.toCharArray();
List<Character> lst = new ArrayList<>();
for(char c: ca){
lst.add(c);
}
============================================
for (Character c: s.toCharArray()){
int first = s.indexOf(c);
int second = s.indexOf(c, first + 1);
if(second == -1){
System.out.println(c);
return c;
}
}
============================================
Custom Code:
String line = "a.b.c.d";
int count = line.length() - line.replace(".", "").length();
============================================
Custom Code:
static int factorial(int n) {
return n <= 1 ? 1 : n * factorial(n-1);
}
============================================
Out of the box:
int[][] TwoDarray = {
{ 1, 0, 12, -1 },
{ 7, -3, 2, 5 },
{ -5, -2, 2, -9 }
};
Custom Code:
for (int i = 0; i < row.length; i++) {
for (int i = 0; i < col.length; i++) {
arr[row][col] = data;
}
}
============================================
Out of the box:
LinkedList.getLast();
Custom Code:
// Iterate through list until last node's current is null
while (current.next != null) {
current = current.next;
}
Out of the box: