diff --git a/Loops.java b/Loops.java new file mode 100644 index 0000000..3a263d6 --- /dev/null +++ b/Loops.java @@ -0,0 +1,35 @@ +public class Loops +{ + public static void number(int x) + { + //using while loop + while (x < 10) { + ++x; + System.out.println(x); + } + } + public static void even(int z) + { + do { + System.out.println (z); + z += 2; + } while (z <= 10); + } + public static void table(int y) + { + //using for loop + int i; + for (i = 1; i <= 10; ++i) { + System.out.println(i*y); + } + } + public static void main(String[] args) + { + System.out.println("Number from 1 to 10"); + number(0); + System.out.println("Even Numbers between 0 to 10"); + even(0); + System.out.println("Table of 8"); + table(8); + } +} diff --git a/README.md b/README.md index 72a8910..d7818d5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Java-Guide-for-Beginners - This will be an Open Guide for all beginners in Python ! You can read and learn simple Java codes here , and whats more interesting is that you can even Contribute !!! +## This will be an Open Guide for all beginners in JAVA! +You can read and learn simple Java codes here , and whats more interesting is that you can even Contribute !!! diff --git a/Selection_Statements.java b/Selection_Statements.java new file mode 100644 index 0000000..d8c71c1 --- /dev/null +++ b/Selection_Statements.java @@ -0,0 +1,36 @@ + +package selectionstatements; + + +public class Selection_Statements { + public static String IfElse(int x){ + if(x%2==0){ + return "even"; + } + else{ + return "odd"; + } + } + public static String Switch(int x){ + switch(x){ + case 1 : + return "it's one"; + case 2 : + return "it's two"; + case 3 : + return "it's three"; + default: + return "out of my knowledge"; + } + } + + + public static void main(String[] args) { + Selection_Statements obj = new Selection_Statements(); + String y = obj.IfElse(123); + System.out.println("The number is "+ y); + String x=obj.Switch(2); + System.out.println("switch statements result is :"+ x); + } + +} diff --git a/class_and_objects/class_object.java b/class_and_objects/class_object.java new file mode 100644 index 0000000..6223c6a --- /dev/null +++ b/class_and_objects/class_object.java @@ -0,0 +1,27 @@ +public class class_object +{ + //class declaration + public int square(int x) + { + return x*2; + } + public double square_rt (int x) + { + return Math.sqrt (x); + } + public static void main(String[] args) + { + // using the command line arguements as input + int x = Integer.parseInt (args[0]); + + Class object = new Class(); // declaring an object for class Class + + int y = object.square (x); // calling a method of class Class + double z = object.square_rt (x); // calling a method of class Class + + System.out.println("Input number = " + x); + System.out.println("Square of number = " + y); + System.out.println("Square root of number = " + z); + } + +} diff --git a/data_structures/infix_to_postfix.java b/data_structures/infix_to_postfix.java new file mode 100644 index 0000000..6a1b59f --- /dev/null +++ b/data_structures/infix_to_postfix.java @@ -0,0 +1,106 @@ +import java.util.Scanner; +import java.util.StringTokenizer; + +/** + * Program to convert infix expression to postfix. + * Input format :- there have to be spaces in between numbers and mathematical signs + * + - * / % ^ ( ) are considered. + * example of input :- a * b - c / d * ( e - f ) ^ g + h + * example of output :- a b * c d / e f - g ^ * - h + + */ +public class infix_to_postfix +{ + public static int precedence(String sign) + { + switch (sign) { + case "+": + case "-": + return 0; + case "*": + case "/": + return 1; + case "%": + return 2; + case "^": + return 3; + case "(": + case ")": + return 4; + default: + return 5; + } + } + + public static void main(String[] args) + { + String St, i; + Scanner Sc = new Scanner (System.in); + Stack stack = new Stack(); + St = Sc.nextLine(); + StringTokenizer obj = new StringTokenizer(St); + for (St = obj.nextToken(); obj.hasMoreTokens(); St = obj.nextToken()) { + if (St.equals("(")) { + stack.push (St); + continue; + } + if (St.equals(")")) { + for (i = stack.top(); !stack.is_empty(); stack.pop(), i = stack.top()) { + if (i.equals("(")) { + stack.pop(); + break; + } else { + System.out.print(i + " "); + } + } + continue; + } + if (St.equals("+") || St.equals("-") || St.equals("*") || St.equals("/") || St.equals("%") || St.equals("^")) { + for ( ; !stack.is_empty(); ) { + i = stack.top(); + if (i.equals("(")) { + break; + } + if (precedence (i) >= precedence (St)) { + System.out.print(i + " "); + stack.pop(); + } else { + break; + } + } + stack.push (St); + } else { + System.out.print(St + " "); + } + } + System.out.print(St + " "); + for ( ; !stack.is_empty(); stack.pop()) { + System.out.print(stack.top() + " "); + } + } +} +class Stack { + private String[] arr; + private int size; + public Stack() + { + size = 0; + arr = new String[10000]; + } + public String top() + { + return arr[size - 1]; + } + public void pop() + { + --size; + } + public void push (String val) + { + arr[size] = val; + ++size; + } + public boolean is_empty() + { + return size == 0; + } +} diff --git a/data_structures/maps_I.java b/data_structures/maps_I.java new file mode 100644 index 0000000..58b1ac5 --- /dev/null +++ b/data_structures/maps_I.java @@ -0,0 +1,63 @@ +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; + +public class maps_I +{ + public static void main(String[] args) + { + Map my_map = new HashMap(); + Scanner Sc = new Scanner(System.in); + int choice; + String St; int key; + do { + choice = Sc.nextInt(); + switch (choice) { + case 1: + // check + key = Sc.nextInt(); + System.out.println(my_map.containsKey(key)); + St = Sc.next(); + System.out.println(my_map.containsValue(St)); + break; + case 2: + // insert + // if key-value pair exists, + // then it replaces the existing pair with the new pair ! + key = Sc.nextInt(); + St = Sc.next(); + my_map.put(key, St); + break; + case 3: + // get value + key = Sc.nextInt(); + System.out.println(my_map.get(key)); + break; + case 4: + // size + System.out.println(my_map.size()); + break; + case 5: + // clear the map + my_map.clear(); + break; + case 6: + // remove an element + key = Sc.nextInt(); + System.out.println("Removed :- " + my_map.get(key)); + my_map.remove(key); + break; + case 7: + System.out.println(my_map); + System.out.println(my_map.keySet()); + System.out.println(my_map.entrySet()); + break; + case 10: + System.exit(0); + break; + default: + System.out.println("Try Again"); + } + } while (true); + } +} diff --git a/data_structures/maps_ex_1.java b/data_structures/maps_ex_1.java new file mode 100644 index 0000000..c901a11 --- /dev/null +++ b/data_structures/maps_ex_1.java @@ -0,0 +1,34 @@ +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Scanner; +/** + * java.util.HashMap is unordered. + * This class makes no guarantees as to the order of the map, + * in particular, it does not guarantee that the order will remain constant over time. + * + * java.util.LinkedHashMap uses insertion-order. + * This implementation differs from HashMap in that it maintains a doubly-linked list running through all of its entries. + * This linked list defines the iteration ordering, + * which is normally the order in which keys were inserted into the map (insertion-order). + * + * java.util.TreeMap, a SortedMap, uses either natural or custom ordering of the keys. + * The map is sorted according to the natural ordering of its keys, + * or by a Comparator provided at map creation time, depending on which constructor is used. + */ +public class maps_ex_1 +{ + public static void main(String[] args) + { + String St; Integer key; + int t; + Scanner Sc = new Scanner(System.in); + Map my_map = new LinkedHashMap(); + for (t = Sc.nextInt(); t > 0; --t) { + St = Sc.next(); + key = my_map.get(St); + my_map.put(St, (key == null) ? 1 : key + 1); + } + System.out.println(my_map.size()); + System.out.println(my_map); + } +} diff --git a/input_output/java_io_I.java b/input_output/java_io_I.java new file mode 100644 index 0000000..1fc6da6 --- /dev/null +++ b/input_output/java_io_I.java @@ -0,0 +1,46 @@ +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.io.IOException; +public class java_io_I +{ + public static void main(String[] args)throws IOException + // throw the Exception class object for input-output exceptions ie. IOException + { + InputStreamReader Isr = new InputStreamReader (System.in); + BufferedReader Br = new BufferedReader (Isr); + + // all inputs are taken as Strings + // also the entire line is taken as input + // Now just parse the String into whichever data type required. + + String input; + int input_i; + long input_l; + float input_f; + double input_d; + char input_c; + + input = Br.readLine(); // Taking input as a String + System.out.println(input); // String Input + + input = Br.readLine(); // Taking input as a String + input_i = Integer.parseInt (input); // parsing input + System.out.println(input_i); + + input = Br.readLine(); // Taking input as a String + input_l = Long.parseLong (input); // parsing input + System.out.println(input_l); + + input = Br.readLine(); // Taking input as a String + input_f = Float.parseFloat (input); // parsing input + System.out.println(input_f); + + input = Br.readLine(); // Taking input as a String + input_d = Double.parseDouble (input); // parsing input + System.out.println(input_d); + + input_c = (char) Br.read(); // Taking input as a character + Br = new BufferedReader (Isr); // flush the junk characters (of newline or carriage return) from the input buffer + System.out.println(input_c); + } +} diff --git a/input_output/java_io_II.java b/input_output/java_io_II.java new file mode 100644 index 0000000..e76282b --- /dev/null +++ b/input_output/java_io_II.java @@ -0,0 +1,36 @@ +import java.util.Scanner; +//import this package for input + +public class java_io_II +{ + public static void main(String[] args) { + //for input + Scanner Sc = new Scanner(System.in); + + // variable "input_x" takes the input for data type x + + // for integer inputs + int input_i = Sc.nextInt(); + System.out.println("Input = " + input_i); + + // for Long_Integer inputs + long input_l = Sc.nextLong(); + System.out.println("Input = " + input_l); + + // for float inputs + float input_f = Sc.nextFloat(); + System.out.println("Input = " + input_f); + + // for double_float inputs + double input_d = Sc.nextDouble(); + System.out.println("Input = " + input_d); + + // for String inputs WORD by WORD + String input_St = Sc.next(); + System.out.println("Input = " + input_St); + + // for String inputs Entire Line + input_St = Sc.nextLine(); + System.out.println("Input = " + input_St); + } +} diff --git a/mathematics/Euclidean_GCD.java b/mathematics/Euclidean_GCD.java new file mode 100644 index 0000000..55afec6 --- /dev/null +++ b/mathematics/Euclidean_GCD.java @@ -0,0 +1,20 @@ +/** +* Euclidean algorithm for finding the GCD of two numbers. +* Time complexity is O(log(max(A, B))) +*/ +public class Euclidean_GCD +{ + public static int gcd(int a, int b) + { + /** + * Iterative solution + */ + int res = 1; + for ( ; a % b != 0; ) { + res = a % b; + a = b; + b = res; + } + return res; + } +} diff --git a/mathematics/binary_expo_I.java b/mathematics/binary_expo_I.java new file mode 100644 index 0000000..07284aa --- /dev/null +++ b/mathematics/binary_expo_I.java @@ -0,0 +1,67 @@ +import java.util.Scanner; +/** + * @author jackdaw14-9 + * @version 1.0 dated 10/08/2017 + */ + /** + * Binary Exponentiation + * for powering two numbers. + * also useful for calculating - (a^b) % c + */ +public class binary_expo_I +{ + public static int b_expo(int a, int b) + { + /* + * iterative solution + */ + int res; + for (res = 1; b > 0; a *= a, b >>= 1) { + if ((b&1) == 1) { + res *= a; + } + } + return res; + /* + * recursive solution + if (b == 0) { + return 1; + } + if (b == 1) { + return a; + } + if ((b & 1) == 1) { + return a * b_expo(a*a, b >> 1); + } else { + return b_expo (a*a, b >> 1); + } + */ + } + public static long b_expo(long a, long b, long c) + { + /* + * iterative solution + */ + long res; + for (res = 1l; b > 0; a *=a, b >>= 1) { + if ((b&1) == 1) { + res = ((res%c) * (a%c)) % c; + } + } + return res; + /* + * recursive solution + if (b == 0) { + return 1; + } + if (b == 1) { + return a; + } + if ((b & 1) == 1) { + return ((a%c) * (b_expo(a*a, b >> 1)%c))%c; + } else { + return b_expo (a*a, b >> 1)%c; + } + */ + } +} diff --git a/mathematics/binary_expo_II.java b/mathematics/binary_expo_II.java new file mode 100644 index 0000000..eb89a34 --- /dev/null +++ b/mathematics/binary_expo_II.java @@ -0,0 +1,76 @@ +/** +* Binary Exponentiation for MULTIPLICATION +* Method to find a*b in O(log(b)) time complexity. +* Also useful in finding solution to (a*b)%c, where a, b, c are WAY OVER THE INTEGER LIMITS. +* +* +* Wondering how it works ?! +* Well, it's quite simple. +* RULE 1 :- a*b = (a+a) * (b/2) +* RULE 2 :- IF b is ODD THEN -- a*b = a + (a * (b - 1)) :: where (b - 1) will be EVEN. NOW apply RULE 1 +* Repeat RULE 1, 2 till b = 0 OR b = 1, because a * 0 = 0 AND a * 1 = a +* +* As far as the MOD is concerned, +* RULE 3 :- (a+b) % c = ((a%c) + (b%c)) % c +* Now, apply RULE 1 or 2, whichever is required. +*/ +public class binary_expo_II +{ + public static int b_expo(int a, int b) + { + /* + * iterative solution + */ + int res; + for (res = 0; b > 0; a += a, b >>= 1) { + if ((b&1) == 1) { + res += a; + } + } + return res; + + /* + * recursive solution + if (b == 0) { + return 0; + } + if (b == 1) { + return a; + } + if ((b & 1) == 1) { + return a + b_expo(a+a, b >> 1); + } else { + return b_expo (a+a, b >> 1); + } + */ + } + + public static long b_expo(long a, long b, long c) + { + /* + * iterative solution + */ + long res; + for (res = 0l; b > 0; a += a, b >>= 1) { + if ((b&1) == 1) { + res = ((res%c) + (a%c)) % c; + } + } + return res; + + /* + * recursive solution + if (b == 0) { + return 0; + } + if (b == 1) { + return a; + } + if ((b & 1) == 1) { + return ((a%c) + (b_expo(a+a, b >> 1)%c))%c; + } else { + return b_expo (a+a, b >> 1)%c; + } + */ + } +} diff --git a/mathematics/remainder.java b/mathematics/remainder.java new file mode 100644 index 0000000..46ae41a --- /dev/null +++ b/mathematics/remainder.java @@ -0,0 +1,27 @@ +/** +* JAVA program to find remainder of a/b +* NOTE -- NUMBER OF DIGITS IN a <= 100000 +*/ +import java.util.Scanner; +public class remainder +{ + public static int function(String a, int b) + { + int res, i, j; + j = a.length(); + for (res = 0, i = 0; i < j; ++i) { + res = (res * 10 + (a.charAt(i) - 48)) % b; + } + return res; + } + public static void main(String[] args) + { + String a; + int b, res; + Scanner Sc = new Scanner(System.in); + a = Sc.next(); + b = Sc.nextInt(); + res = function (a, b); + System.out.println(res); + } +} diff --git a/mathematics/set_bits.java b/mathematics/set_bits.java new file mode 100644 index 0000000..d7c6bf4 --- /dev/null +++ b/mathematics/set_bits.java @@ -0,0 +1,15 @@ +/** + * Brian Kernighan's algorithm for finding number of set bits in a number. + * Time Complexity -- O(logn) + */ +public class set_bits +{ + public static int function(int a) + { + int count; + for (count = 0; a > 0; ++count) { + a = a & (a - 1); + } + return count; + } +} diff --git a/sorting/bubble_sort.java b/sorting/bubble_sort.java new file mode 100644 index 0000000..aa9c65c --- /dev/null +++ b/sorting/bubble_sort.java @@ -0,0 +1,36 @@ +import java.util.Scanner; +public class bubble_sort +{ + public static void sorting(int[] arr) + { + // Bubble sorting in Ascending Order + int i, j, temp; + for (i = 0; i < arr.length; ++i) { + for (j = 0; j < arr.length - i - 1; ++j) { + if (arr[j] > arr[j + 1]) { + temp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = temp; + } + } + } + } + public static void main(String[] args) + { + int i, size; + Scanner Sc = new Scanner (System.in); + System.out.print("Enter size of array :- "); + size = Sc.nextInt(); + int[] arr = new int[size]; + System.out.print("Enter elements :- "); + for (i = 0; i < size; ++i) { + arr[i] = Sc.nextInt(); + } + sorting(arr); + System.out.println("Sorted array :-"); + for (i = 0; i < size; ++i) { + System.out.print(arr[i] + " "); + } + System.out.println(); + } +} diff --git a/sorting/insertion_sort.java b/sorting/insertion_sort.java new file mode 100644 index 0000000..cae71d3 --- /dev/null +++ b/sorting/insertion_sort.java @@ -0,0 +1,34 @@ +import java.util.Scanner; +public class selection_sort +{ + public static void sorting(int[] arr) + { + // Selection sorting in Ascending Order + int i, j, key; + for (i = 1; i < arr.length; ++i) { + key = arr[i]; + for (j = i - 1; j >= 0 && arr[j] > key; --j) { + arr[j + 1] = arr[j]; + } + arr[j + 1] = key; + } + } + public static void main(String[] args) + { + int i, size; + Scanner Sc = new Scanner (System.in); + System.out.print("Enter size of array :- "); + size = Sc.nextInt(); + int[] arr = new int[size]; + System.out.print("Enter elements :- "); + for (i = 0; i < size; ++i) { + arr[i] = Sc.nextInt(); + } + sorting(arr); + System.out.println("Sorted array :-"); + for (i = 0; i < size; ++i) { + System.out.print(arr[i] + " "); + } + System.out.println(); + } +} diff --git a/sorting/merge_sort.java b/sorting/merge_sort.java new file mode 100644 index 0000000..d339fe7 --- /dev/null +++ b/sorting/merge_sort.java @@ -0,0 +1,74 @@ +import java.util.Scanner; +public class merge_sort +{ + /** + * Merge sorting + * a divide and conquer based sorting method. + * You divide the array into two parts from the middle. + * Now sort both the parts and merge them later on. + * You keep dividing till you get arrays of size = 1, + * because an array of size = 1 is always sorted. + */ + public static void sorting(int[] arr, int i, int j) + { + if (i < j) { + int m = (i + j) / 2; + sorting (arr, i, m); + sorting (arr, m + 1, j); + merging (arr, i, m, j); + } + } + public static void merging (int[] arr, int i, int m, int j) + { + int[] l = new int[m - i + 1]; + int[] r = new int[j - m]; + int x, y, a, b; + for (x = 0, a = i; a <= m; ++x, ++a) { + l[x] = arr[a]; + } + for (y = 0; a <= j; ++y, ++a) { + r[y] = arr[a]; + } + for (a = 0, b = 0; a < x && b < y; ++i) { + if (l[a] <= r[b]) { + arr[i] = l[a]; + ++a; + } else { + arr[i] = r[b]; + ++b; + } + } + for ( ; a < x; ++a, ++i) { + arr[i] = l[a]; + } + for ( ; b < y; ++b, ++i) { + arr[i] = r[b]; + } + } + public static void display(int[] arr) + { + int i; + for (i = 0; i < arr.length; ++i) { + System.out.print(arr[i] + " "); + } + System.out.println(); + } + public static void main(String[] args) + { + int i, size; + Scanner Sc = new Scanner (System.in); + System.out.print("Enter size of array :- "); + size = Sc.nextInt(); + int[] arr = new int[size]; + System.out.print("Enter elements :- "); + for (i = 0; i < size; ++i) { + arr[i] = Sc.nextInt(); + } + sorting(arr, 0, size - 1); + System.out.println("Sorted array :-"); + for (i = 0; i < size; ++i) { + System.out.print(arr[i] + " "); + } + System.out.println(); + } +} diff --git a/sorting/quick_sort.java b/sorting/quick_sort.java new file mode 100644 index 0000000..0c3e7fb --- /dev/null +++ b/sorting/quick_sort.java @@ -0,0 +1,65 @@ +import java.util.Scanner; +public class quick_sort +{ + /** + * Quick sorting + * a divide-based sorting method. + * You take an element (preferably the last) -- PIVOT, + * now divide the array into two parts, + * front part has elements less than or equal to PIVOT + * rear part has elements grater than PIVOT + * now use quick sorting on both the parts. + */ + public static int partition(int arr[], int low, int high) + { + int pivot = arr[high]; + int i, j; // index of smaller element + for (i = low - 1, j = low; j < high; ++j) { + if (arr[j] <= pivot) { + ++i; + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + int temp = arr[i+1]; + arr[i+1] = arr[high]; + arr[high] = temp; + + return i + 1; + } + public static void sorting (int[] arr, int i, int j) + { + if (i < j) { + int p = partition (arr, i, j); + sorting (arr, i, p - 1); + sorting (arr, p + 1, j); + } + } + public static void display(int[] arr) + { + int i; + for (i = 0; i < arr.length; ++i) { + System.out.print(arr[i] + " "); + } + System.out.println(); + } + public static void main(String[] args) + { + int i, size; + Scanner Sc = new Scanner (System.in); + System.out.print("Enter size of array :- "); + size = Sc.nextInt(); + int[] arr = new int[size]; + System.out.print("Enter elements :- "); + for (i = 0; i < size; ++i) { + arr[i] = Sc.nextInt(); + } + sorting(arr, 0, size - 1); + System.out.println("Sorted array :-"); + for (i = 0; i < size; ++i) { + System.out.print(arr[i] + " "); + } + System.out.println(); + } +} diff --git a/sorting/selection_sort.java b/sorting/selection_sort.java new file mode 100644 index 0000000..5c804d1 --- /dev/null +++ b/sorting/selection_sort.java @@ -0,0 +1,36 @@ +import java.util.Scanner; +public class selection_sort +{ + public static void sorting(int[] arr) + { + // Selection sorting in Ascending Order + int i, j, p, temp; + for (i = 0; i < arr.length; ++i) { + p = i; + for (j = i + 1; j < arr.length; ++j) { + p = arr[j] < arr[p] ? j : p; + } + temp = arr[i]; + arr[i] = arr[p]; + arr[p] = temp; + } + } + public static void main(String[] args) + { + int i, size; + Scanner Sc = new Scanner (System.in); + System.out.print("Enter size of array :- "); + size = Sc.nextInt(); + int[] arr = new int[size]; + System.out.print("Enter elements :- "); + for (i = 0; i < size; ++i) { + arr[i] = Sc.nextInt(); + } + sorting(arr); + System.out.println("Sorted array :-"); + for (i = 0; i < size; ++i) { + System.out.print(arr[i] + " "); + } + System.out.println(); + } +} diff --git a/sorting/sorting b/sorting/sorting new file mode 100644 index 0000000..131086e --- /dev/null +++ b/sorting/sorting @@ -0,0 +1,72 @@ +import java.util.Scanner; +import java.util.Comparator; +import java.util.Arrays; +public class sorting +{ + /** + * This makes use of the Generic Sorting method provided in JAVA + * This sorts the given array of any type. + * The comparator class object specifies how the sorting is to be done. + */ + public static void main(String[] args) throws Exception + { + int i, size; + Scanner Sc = new Scanner(System.in); + size = Sc.nextInt(); + req_data[] arr = new req_data[size]; + for (i = 0; i < size; ++i) { + arr[i] = new req_data(); + arr[i].set_name (Sc.next()); + arr[i].set_val (Sc.nextInt()); + } + Arrays.sort (arr, 0, size, new myComp()); + for (i = 0; i < size; ++i) { + System.out.println(arr[i].get_name() + " " + arr[i].get_val()); + } + } +} +class req_data +{ + private String name; + private int val; + public void set_name (String name) + { + this.name = name; + } + public void set_val (int val) + { + this.val = val; + } + public String get_name() + { + return name; + } + public int get_val() + { + return val; + } +} +class myComp implements Comparator +{ + /** + * Sorting is done by val (increasing), + * then by name (decreasing) + */ + public int compare(req_data obj0, req_data obj1) + { + if (obj0.get_val() > obj1.get_val()) { + return 1; + } else if (obj0.get_val() == obj1.get_val()) { + int c = obj0.get_name().compareTo (obj1.get_name()); + if (c < 0) { + return 1; + } else if (c == 0) { + return 0; + } else { + return -1; + } + } else { + return -1; + } + } +} diff --git a/spring_test_1/pom.xml b/spring_test_1/pom.xml new file mode 100644 index 0000000..27883d5 --- /dev/null +++ b/spring_test_1/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + com.example + test-one + 0.0.1-SNAPSHOT + jar + + test-one + First Sample of SpringBoot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.2.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-web + + + + mysql + mysql-connector-java + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + +