Skip to content

Instantly share code, notes, and snippets.

@marisnb
Created June 24, 2019 14:31
Show Gist options
  • Save marisnb/93771c6e6829495d5862aabc6a1c5ad0 to your computer and use it in GitHub Desktop.
Save marisnb/93771c6e6829495d5862aabc6a1c5ad0 to your computer and use it in GitHub Desktop.
class SortingArray {
public static void main (String args[]) {
String date = "01/01/2019";
int days = 10;
System.out.println("EX :- 1");
System.out.println("----------");
System.out.println(String.valueOf(Integer.parseInt(date.substring(0,2)) + days) + date.substring(2));
System.out.println("");
System.out.println("EX :- 2");
System.out.println("----------");
String [] list = {"d","c","e","a","b"};
for(int i = 1; i < list.length; i++) {
if(list[i].compareTo(list[i - 1]) < 0) {
String temp = list[i];
list[i] = list[i - 1];
list[i - 1] = temp;
i = 0;
}
}
System.out.println(Arrays.toString(list));
System.out.println("");
System.out.println("EX :- 3");
System.out.println("----------");
System.out.println((days & 1) == 0 ? "Even":"ODD");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment