Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public static String toProperCase(String s) {
  2. String firstLetter;
  3.  
  4. s = s.trim();
  5.  
  6. firstLetter = s.substring(0, 1).toUpperCase();
  7.  
  8. return firstLetter + s.substring(1).toLowerCase();
  9. }
  10.  
  11.  
  12. // Double array length and save data(for Participant array)
  13.  
  14. public Event[] doubleArrayLength(Event[] a) {
  15.  
  16. Event[] newArray;
  17.  
  18. // Create new array with double length
  19. newArray = new Event[a.length * 2];
  20.  
  21. // Transfer all data to new array
  22. for (int i = 0; i < a.length; i++) {
  23. if (a[i] != null)
  24. newArray[i] = a[i];
  25. }
  26.  
  27. return newArray;
  28.  
  29. }
  30.  
  31. public static boolean validateEmptyString(String input) {
  32. if (input.equals("") || input.trim().length() == 0) {
  33. System.out.println("Value can't be empy!");
  34. return false;
  35. } else
  36. return true;
  37. }
  38.  
  39. public static boolean validateEmptyInt(Integer input) {
  40. if (input == null) {
  41. System.out.println("Value can't be empy!");
  42. return false;
  43. } else
  44. return true;
  45. }
  46.  
  47.  
  48. // Add one row and save data (for int matrix)
  49.  
  50. public static int[][] incrementMatrixRowLength(int[][] a) {
  51.  
  52. int[][] newArray;
  53.  
  54. // Create new array with double length
  55. newArray = new int[a.length + 1][4];
  56.  
  57. // Transfer all data to new array
  58. for (int i = 0; i < a.length; i++) {
  59. for (int j = 0; j < a[0].length; j++) {
  60. newArray[i][j] = a[i][j];
  61. }
  62. }
  63.  
  64. return newArray;
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement