diff --git a/JavaApplication1.java b/JavaApplication1.java new file mode 100644 index 0000000..0920024 --- /dev/null +++ b/JavaApplication1.java @@ -0,0 +1,59 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package javaapplication1; + +import static jdk.nashorn.api.scripting.ScriptUtils.convert; + +/** + * + * @author Parthkharva + */ +public class JavaApplication1 { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + int a = 10; + int b = 52; + float x= 123.4556655f; + System.out.println(x); + + double dd = 456/45; + System.out.println(dd); + + String c = "parth"; + String name = null; + System.out.println("name:"+c+" : "+name); + + int d =++b; + System.out.println(d); + + int e =b++; + System.out.println(e); + + int f = a--; + System.out.println(f); + + int g = --a; + System.out.println(g); + + int h = a+b; + System.out.println(h); + + int i = a-b; + System.out.println(f); + + int j = a*b; + System.out.println(j); + + int k = a/b; + System.out.println(k); + + boolean bl = true; + System.out.println(bl); + System.out.println(!bl); + } +} diff --git a/Parth_Kharva/1D_Array_implementation.java b/Parth_Kharva/1D_Array_implementation.java new file mode 100644 index 0000000..40d3511 --- /dev/null +++ b/Parth_Kharva/1D_Array_implementation.java @@ -0,0 +1,78 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package pkg1d_array; + +/** + * + * @author Parthkharva + */ +public class Main { + + /** + * @param args the command line arguments + */ + + public static void main(String[] args) { + //types of array declaration + int a[]; + int[] b = new int[10]; + //assign a value in a two ways + int[] numbers = {178, 299, 375, 412, 5, 16, 78, 80, 91};//at compile time + //or + int[] no = new int[3]; + no[0]=10; + no[1]=20; + no[2]=30; + + // print array Values: + System.out.println("Array values of no : "); + for(int x=0; x 'Z') { + shiftedLetter = (char) (shiftedLetter + 'A' - 'Z' - 1); + } + result += shiftedLetter; + } + return result; + } + + public static String Decrypt(String text, int positions) { + //encrypted code is already uppercase, + String result = ""; + for (int i = 0; i < text.length(); i++) { + + //shift the current letter of the message with given positions to left + char shiftedLetter = (char) (text.charAt(i) - positions); + + //if the ASCII code exceeds A, then bring it back in the interval A..Z + if (shiftedLetter < 'A') { + shiftedLetter = (char) (shiftedLetter - 'A' + 'Z' + 1); + } + result += shiftedLetter; + + } + + return result; + } + + public static void main(String[] args) { + //message input code + System.out.println("CAESAR CIPHER"); + Scanner sc = new Scanner(System.in); + System.out.println("Type Your Important Message : "); + String message = sc.nextLine(); + System.out.print("Type the key: "); + int key = sc.nextInt(); + sc.close(); + System.out.println("\n"); + + // message Encryption code + System.out.println("Process : Encrypting..."); + String encryptedMessage = Encrypt(message, key); + System.out.println("The encrypted message is: " + encryptedMessage); + System.out.println("\n"); + System.out.println("Process : Encryption Complete..."); + + // message Dencryption code + System.out.println("Process : Decrypting..."); + String restoredMessage = Decrypt(encryptedMessage, key); + System.out.println("The Decrypted message is: " + restoredMessage); + System.out.println("Process : Decryption Complete..."); + } +} diff --git a/Parth_Kharva/DRDO Cryptography and Cryptanalysis Project/Implement Caesar Cipher in Java/Encryption_Portion_Of _Caesar_Cipher.java b/Parth_Kharva/DRDO Cryptography and Cryptanalysis Project/Implement Caesar Cipher in Java/Encryption_Portion_Of _Caesar_Cipher.java new file mode 100644 index 0000000..b3351d5 --- /dev/null +++ b/Parth_Kharva/DRDO Cryptography and Cryptanalysis Project/Implement Caesar Cipher in Java/Encryption_Portion_Of _Caesar_Cipher.java @@ -0,0 +1,69 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package caesarciphe; + +import java.util.Scanner; + +/** + * + * @author Parthkharva + */ +public class Caesarciphe { + + /** + * @param args the command line arguments + */ + public static String Encrypt(String text, int positions) { + String toEncrypt = ""; + String result = ""; + //Message encrypted + for (int i = 0; i < text.length(); i++) { + //remove spacings + + if (text.charAt(i) == ' ') { + continue; + } else { + //convert lowercase to uppercase + if (Character.isLowerCase(text.charAt(i))) { + toEncrypt += Character.toUpperCase(text.charAt(i)); + } //if already uppercase keep the uppercase character + else { + toEncrypt += text.charAt(i); + } + } + } + for (int i = 0; i < toEncrypt.length(); i++) { + //shift the current letter of the message with given positions from right. + char shiftedLetter = (char) (toEncrypt.charAt(i) + positions); + + //if the ASCII code exceeds Z, then bring it back in the interval A..Z + if (shiftedLetter > 'Z') { + shiftedLetter = (char) (shiftedLetter + 'A' - 'Z' - 1); + } + + result += shiftedLetter; + } + + return result; + + } + public static void main(String[] args) { + //message input code + System.out.println("CAESAR CIPHER"); + Scanner sc = new Scanner(System.in); + System.out.println("Type Your Important Message : "); + String message = sc.nextLine(); + System.out.println("Type the key: "); + int key = sc.nextInt(); + sc.close(); + System.out.println("\n"); + + // message Encrytion code + System.out.println("Encrypting..."); + String encryptedMessage = Encrypt(message, key); + System.out.println("The encrypted message is: " +encryptedMessage); + } + +} diff --git a/Parth_Kharva/Data Structure/Advance_Exception_Handling.java b/Parth_Kharva/Data Structure/Advance_Exception_Handling.java new file mode 100644 index 0000000..48dbcd3 --- /dev/null +++ b/Parth_Kharva/Data Structure/Advance_Exception_Handling.java @@ -0,0 +1,55 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package finally_block_exception_handling; + +import java.util.InputMismatchException; +import java.util.Scanner; + +/** + * + * @author Parthkharva + */ +public class Finally_block_exception_handling { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + try{ + System.out.println("-: Welcome to my Addition Calculator Tool :-"); + Scanner sc = new Scanner(System.in); + + System.out.println("Please Enter First Numeric Value :"); + int no1 = sc.nextInt(); + + System.out.println("Please Enter Second Numeric Value :"); + int no2 = sc.nextInt(); + + int op = addition(no1, no2); + System.out.println("The Output is : "+op+"."); + } + catch(InputMismatchException e){ + System.out.println("Please Enter Intiger Only."); + } + finally{ + System.out.println("Intiger Not Found."); + } + } + + public static int addition(int a, int b){ + int add = 0; + try{ + add = a+b; + } + catch(Exception e){ + System.out.println("Please Enter Intiger Only."); + } + finally{ + System.out.println("This is a finally block."); + } + return add; + } + +} diff --git a/Parth_Kharva/Data Structure/ArrayDeque.java b/Parth_Kharva/Data Structure/ArrayDeque.java new file mode 100644 index 0000000..51cf253 --- /dev/null +++ b/Parth_Kharva/Data Structure/ArrayDeque.java @@ -0,0 +1,40 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package stack_using_arraydeque; + +import java.util.ArrayDeque; +import java.util.Iterator; + +/** + * + * @author Parthkharva + */ +public class Stack_using_arraydeque { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + + ArrayDeque mydeque = new ArrayDeque(); + mydeque.add("Ashish"); + mydeque.addFirst("Parth"); + mydeque.addLast("Parit"); + mydeque.offerFirst("Riya"); + mydeque.offer("Piya"); + + System.out.println("First Element : "+mydeque.getFirst()); + System.out.println("Last Element : "+mydeque.getLast()); + System.out.println("Deque Contains 'Parth' : "+mydeque.contains("Parth")); + System.out.println("Iterating All The Elements In Decending Order : "); + Iterator myiterator = mydeque.descendingIterator(); + + while(myiterator.hasNext()){ + System.out.println(myiterator.next()); + } + + } + +} diff --git a/Parth_Kharva/Data Structure/Array_List.java b/Parth_Kharva/Data Structure/Array_List.java new file mode 100644 index 0000000..20a6aee --- /dev/null +++ b/Parth_Kharva/Data Structure/Array_List.java @@ -0,0 +1,55 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package arraylist; + +import java.util.ArrayList; + +/** + * + * @author Parthkharva + */ +public class array_list { + public static void main(String[] args) { + // TODO code application logic here + System.out.println("My Array list :"); + ArrayList myarraylist = new ArrayList(); + myarraylist.add(1);//starting index 0 + myarraylist.add(2); + myarraylist.add(3); + + System.out.println(myarraylist.get(0)); + System.out.println(myarraylist.get(1)); + System.out.println(myarraylist.get(2)); + + myarraylist.add(2,89);//change at index 2 + System.out.println("My UPdated element is : "+ myarraylist.get(2)+"\n"); + System.out.println("My Updated Array list :"); + + ArrayList myarraylist2 = new ArrayList(); + myarraylist2.addAll(myarraylist); + System.out.println(myarraylist2.get(0)); + System.out.println(myarraylist2.get(1)); + System.out.println(myarraylist2.get(2)); + System.out.println(myarraylist2.get(3)+"\n"); + + myarraylist2.clear(); + try{ + System.out.println(myarraylist2.get(0)); + System.out.println(myarraylist2.get(1)); + System.out.println(myarraylist2.get(2)); + System.out.println(myarraylist2.get(3)); + } + catch(IndexOutOfBoundsException e){ + System.out.println("My array List is clear. \n"); + } + + ArrayList clonelist = (ArrayList) myarraylist.clone(); + System.out.println("My Clone List :"); + System.out.println(myarraylist.get(0)); + System.out.println(myarraylist.get(1)); + System.out.println(myarraylist.get(2)); + System.out.println(myarraylist.get(3)); + } +} diff --git a/Parth_Kharva/Data Structure/Array_List_Parallel_Processing_Using_Spliterator.java b/Parth_Kharva/Data Structure/Array_List_Parallel_Processing_Using_Spliterator.java new file mode 100644 index 0000000..5ae9f5a --- /dev/null +++ b/Parth_Kharva/Data Structure/Array_List_Parallel_Processing_Using_Spliterator.java @@ -0,0 +1,50 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package arraylist_parallel_processing_using_spliterator; + +import java.util.ArrayList; +import java.util.Spliterator; + +/** + * + * @author Parthkharva + */ +public class Arraylist_parallel_processing_using_spliterator { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + ArrayList insta_post = new ArrayList(); + + insta_post.add("post1"); + insta_post.add("post2"); + insta_post.add("post3"); + insta_post.add("post4"); + insta_post.add("post5"); + insta_post.add("post6"); + + Spliterator spl1 = insta_post.spliterator(); + Spliterator spl2 = spl1.trySplit(); + System.out.println("SPL1 Estimated size of data : "+spl1.estimateSize()); + System.out.println("SPL1 Exact size : "+spl1.getExactSizeIfKnown()); + + spl1.forEachRemaining(System.out::println); + + System.out.println("SPL1 Estimated size of data : "+spl1.estimateSize()); + System.out.println("SPL1 Exact size : "+spl1.getExactSizeIfKnown()); + + System.out.println("SPL2 Estimated size of data : "+spl2.estimateSize()); + System.out.println("SPL2 Exact size : "+spl2.getExactSizeIfKnown()); + + spl2.forEachRemaining(System.out::println); + + System.out.println("SPL1 Estimated size of data : "+spl1.estimateSize()); + System.out.println("SPL1 Exact size : "+spl1.getExactSizeIfKnown()); + + + } + +} diff --git a/Parth_Kharva/Data Structure/Binary_tree_Creation_Insertion_Traversal.java b/Parth_Kharva/Data Structure/Binary_tree_Creation_Insertion_Traversal.java new file mode 100644 index 0000000..0835a7f --- /dev/null +++ b/Parth_Kharva/Data Structure/Binary_tree_Creation_Insertion_Traversal.java @@ -0,0 +1,81 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package binary_tree_creation_insert_traversal; + +import binary_tree_creation_insert_traversal.Binary_tree_creation_insert_traversal.Tree.Node; + +/** + * + * @author Parthkharva + */ +public class Binary_tree_creation_insert_traversal { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Tree tree = new Tree(); + Node root = new Node(50); + tree.insert(root, 12); + tree.insert(root, 1); + tree.insert(root, 26); + tree.insert(root, 10); + tree.insert(root, 2); + tree.insert(root, 62); + tree.insert(root, 152); + tree.insert(root, 129); + tree.insert(root, 17); + tree.insert(root, 100); + + System.out.println("Travers the tree :"); + tree.traversal_inorder(root); + } + + public static class Tree { + + static class Node { + + int value; + Node left, right; + + Node(int value) { + this.value = value; + + left = null; + right = null; + } + + } + public void insert(Node node,int value){ + if(valuenode.value){ + if(node.right != null){ + insert(node.right,value); + } + else{ + System.out.println("Insert "+value +" to the right of "+node.value+"."); + node.right = new Node(value); + } + } + } + + public void traversal_inorder(Node node){ + if(node != null){ + traversal_inorder(node.left); + System.out.println(" "+node.value); + traversal_inorder(node.right); + } + } + } + +} diff --git a/Parth_Kharva/Data Structure/Binary_tree_Pre-order_&_Post-oder_Traversal.java b/Parth_Kharva/Data Structure/Binary_tree_Pre-order_&_Post-oder_Traversal.java new file mode 100644 index 0000000..0e360df --- /dev/null +++ b/Parth_Kharva/Data Structure/Binary_tree_Pre-order_&_Post-oder_Traversal.java @@ -0,0 +1,101 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package binary_tree_creation_insert_traversal; + +import binary_tree_creation_insert_traversal.Binary_tree_creation_insert_traversal.Tree.Node; + +/** + * + * @author Parthkharva + */ +public class Binary_tree_creation_insert_traversal { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Tree tree = new Tree(); + Node root = new Node(50); + tree.insert(root, 12); + tree.insert(root, 1); + tree.insert(root, 26); + tree.insert(root, 10); + tree.insert(root, 2); + tree.insert(root, 62); + tree.insert(root, 152); + tree.insert(root, 129); + tree.insert(root, 17); + tree.insert(root, 100); + + System.out.println("Travers the tree :"); + tree.traversal_inorder(root); + + System.out.println("Travers the tree in pre-order :"); + tree.traversal_preorder(root); + + System.out.println("Travers the tree in post-order :"); + tree.traversal_postorder(root); + } + + public static class Tree { + + static class Node { + + int value; + Node left, right; + + Node(int value) { + this.value = value; + + left = null; + right = null; + } + + } + public void insert(Node node,int value){ + if(valuenode.value){ + if(node.right != null){ + insert(node.right,value); + } + else{ + System.out.println("Insert "+value +" to the right of "+node.value+"."); + node.right = new Node(value); + } + } + } + + public void traversal_inorder(Node node){ + if(node != null){ + traversal_inorder(node.left); + System.out.println(" "+node.value); + traversal_inorder(node.right); + } + } + public void traversal_preorder(Node node){ + if(node != null){ + System.out.println(" "+node.value); + traversal_inorder(node.left); + traversal_inorder(node.right); + } + } + public void traversal_postorder(Node node){ + if(node != null){ + traversal_inorder(node.left); + traversal_inorder(node.right); + System.out.println(" "+node.value);; + } + } + } + +} diff --git a/Parth_Kharva/Data Structure/Chained_Exception.java b/Parth_Kharva/Data Structure/Chained_Exception.java new file mode 100644 index 0000000..f5b5733 --- /dev/null +++ b/Parth_Kharva/Data Structure/Chained_Exception.java @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package chainedexception; + +import java.util.InputMismatchException; +import java.util.Scanner; + +/** + * + * @author Parthkharva + */ +public class ChainedException { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + try{ + System.out.println("-: Welcome To My Weight Checking Tool :-"); + Scanner sc = new Scanner(System.in); + + System.out.print("Please Enter Your height in centimeters:"); + float height = sc.nextFloat(); + double idealweight = 50 + (0.91 * (height - 152.4)); + + System.out.println("Your Ideal Weight Should be "+idealweight+" KG."); + } + catch(InputMismatchException e){ + throw new NumberFormatException(); + } + finally{ + System.out.println("-: Thank You For Using My Tool :-"); + } + } + +} diff --git a/Parth_Kharva/Data Structure/Exception_Handling.java b/Parth_Kharva/Data Structure/Exception_Handling.java new file mode 100644 index 0000000..e24eb19 --- /dev/null +++ b/Parth_Kharva/Data Structure/Exception_Handling.java @@ -0,0 +1,37 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package exception_handling; + +import java.util.InputMismatchException; +import java.util.Scanner; + +/** + * + * @author Parthkharva + */ +public class Exception_handling { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + try{ + System.out.println("-: Welcome to my Heart Rate Calculator Tool :-"); + Scanner sc = new Scanner(System.in); + + System.out.println("Please Enter Your Right Age Sir/Ma'am :"); + int age = sc.nextInt(); + int MaxRate = 220 - age; + + System.out.println("Your Maximum Heart Rate Should be: "+MaxRate+"."); + System.out.println("-: Thank You For Using My Tool :-"); + } + catch(InputMismatchException e){ + System.out.println("Please Enter Your Age In Numeric Formate, Please Try Again."); + } + + } + +} diff --git a/Parth_Kharva/Data Structure/List_Interface.java b/Parth_Kharva/Data Structure/List_Interface.java new file mode 100644 index 0000000..08358f8 --- /dev/null +++ b/Parth_Kharva/Data Structure/List_Interface.java @@ -0,0 +1,140 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package list_interface; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +/** + * + * @author Parthkharva + */ +public class List_interface implements List{ + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + // TODO code application logic here + } + + @Override + public int size() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean isEmpty() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean contains(Object o) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public Iterator iterator() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public Object[] toArray() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public T[] toArray(T[] a) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean add(String e) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean remove(Object o) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean containsAll(Collection c) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean addAll(Collection c) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean addAll(int index, Collection c) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean removeAll(Collection c) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean retainAll(Collection c) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public void clear() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public String get(int index) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public String set(int index, String element) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public void add(int index, String element) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public String remove(int index) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public int indexOf(Object o) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public int lastIndexOf(Object o) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public ListIterator listIterator() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public ListIterator listIterator(int index) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public List subList(int fromIndex, int toIndex) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + +} diff --git a/Parth_Kharva/Data Structure/Node.java b/Parth_Kharva/Data Structure/Node.java new file mode 100644 index 0000000..3fe7f2f --- /dev/null +++ b/Parth_Kharva/Data Structure/Node.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package node_creation.trees_basic; + +/** + * + * @author Parthkharva + */ +public class Node_CreationTrees_basic { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Node node = new Node(15); + node.left = new Node(12); + node.right = new Node(29); + } + static class Node{ + int value; + Node left,right; + Node(int value){ + this.value = value; + + left = null; + right = null; + } + } + +} diff --git a/Parth_Kharva/Data Structure/Priority Queue/PriorityQueue_MainClass.java b/Parth_Kharva/Data Structure/Priority Queue/PriorityQueue_MainClass.java new file mode 100644 index 0000000..74b484b --- /dev/null +++ b/Parth_Kharva/Data Structure/Priority Queue/PriorityQueue_MainClass.java @@ -0,0 +1,51 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package priority_queue; + +import java.util.Iterator; +import java.util.PriorityQueue; + +/** + * + * @author Parthkharva + */ +public class Priority_queue { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + PriorityQueue pq = new PriorityQueue(); + System.out.println("Is PQ Empty : "+pq.isEmpty()); + + new_Comparator_Of_PQ new_compar = new new_Comparator_Of_PQ(); + PriorityQueue pq1 = new PriorityQueue(new_compar); + + pq.add(34); + pq1.add(34); + + pq.add(26); + pq1.add(26); + + pq.add(1); + pq1.add(1); + + pq.add(100); + pq1.add(100); + + Iterator pq_it = pq.iterator(); + Iterator pq1_it = pq1.iterator(); + System.out.println("PQ Priority Queue :"); + while(pq_it.hasNext()){ + System.out.println(pq_it.next()); + } + System.out.println("PQ1 Priority Queue :"); + while(pq1_it.hasNext()){ + System.out.println(pq1_it.next()); + } + + } + +} diff --git a/Parth_Kharva/Data Structure/Priority Queue/comparatorclass.java b/Parth_Kharva/Data Structure/Priority Queue/comparatorclass.java new file mode 100644 index 0000000..b392ff3 --- /dev/null +++ b/Parth_Kharva/Data Structure/Priority Queue/comparatorclass.java @@ -0,0 +1,22 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package priority_queue; + +import java.util.Comparator; + +/** + * + * @author Parthkharva + */ +public class new_Comparator_Of_PQ implements Comparator { + public int compare(Integer p1, Integer p2){ + if(p1>=p2){ + return p1; + } + else{ + return p2; + } + } +} diff --git a/Parth_Kharva/Data Structure/Single And Multipal Inheritance/BMI_Class.java b/Parth_Kharva/Data Structure/Single And Multipal Inheritance/BMI_Class.java new file mode 100644 index 0000000..1653ea6 --- /dev/null +++ b/Parth_Kharva/Data Structure/Single And Multipal Inheritance/BMI_Class.java @@ -0,0 +1,19 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package single_._multipal_inheritance; + +/** + * + * @author Parthkharva + */ +public class BMI_Mechine_Result extends Single__multipal_inheritance{ + public static void main(String[] args){ + System.out.println(getMax_Heart_Rate(45)); + } + public static int getMax_Heart_Rate(int age){ + System.out.println("This is the BMI Mechine Generated Heart Rate Result :"); + return 230 - age ; + } +} diff --git a/Parth_Kharva/Data Structure/Single And Multipal Inheritance/class1.java b/Parth_Kharva/Data Structure/Single And Multipal Inheritance/class1.java new file mode 100644 index 0000000..0738913 --- /dev/null +++ b/Parth_Kharva/Data Structure/Single And Multipal Inheritance/class1.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package single_._multipal_inheritance; + +import static single_._multipal_inheritance.BMI_Mechine_Result.getMax_Heart_Rate; + +/** + * + * @author Parthkharva + */ +public class Single__multipal_inheritance { + + /** + * @param args the command line arguments + */ + public String maximum_heart_rate; + public static void main(String[] args) { + System.out.println(getMax_Heart_Rate(45)); + } + public static int getMax_Heart_Rate(int age){ + int result = 0; + result = 220 - age; + System.out.print("This is the base class Generated Heart Rate Result :"); + return result; + } + +} diff --git a/Parth_Kharva/Data Structure/Stack.java b/Parth_Kharva/Data Structure/Stack.java new file mode 100644 index 0000000..2af41d2 --- /dev/null +++ b/Parth_Kharva/Data Structure/Stack.java @@ -0,0 +1,30 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package My_Stack; + +import java.util.Stack; + +/** + * + * @author Parthkharva + */ +public class My_Stack { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + // TODO code application logic here + Stack instack = new Stack(); + System.out.println("Is Stack Empty : "+instack.empty()); + instack.push(40); + instack.push(2); + System.out.println("Get the top element : "+instack.peek()); + System.out.println("Is Stack Contains 2 : "+instack.search(2)); + instack.pop(); + System.out.println("Top element after pop operation : "+instack.peek()); + } + +} diff --git a/Parth_Kharva/Data Structure/Throw_Exception.java b/Parth_Kharva/Data Structure/Throw_Exception.java new file mode 100644 index 0000000..85a572f --- /dev/null +++ b/Parth_Kharva/Data Structure/Throw_Exception.java @@ -0,0 +1,35 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package throw_exception; + +import java.util.Scanner; + +/** + * + * @author Parthkharva + */ +public class Throw_exception { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + System.out.println("-: Welcome to my Heart Rate Calculator Tool :-"); + Scanner sc = new Scanner(System.in); + + System.out.println("Please Enter Your Right Age Sir/Ma'am :"); + int age = sc.nextInt(); + + if (age <= 0) { + throw new NumberFormatException(); + } else if (age >= 120) { + throw new NumberFormatException(); + } + int MaxRate = 220 - age; + System.out.println("Your Maximum Heart Rate Should be: " + MaxRate + "."); + System.out.println("-: Thank You For Using My Tool :-"); + } + +} diff --git a/Parth_Kharva/Data Structure/ToArray_Function.java b/Parth_Kharva/Data Structure/ToArray_Function.java new file mode 100644 index 0000000..660f0ab --- /dev/null +++ b/Parth_Kharva/Data Structure/ToArray_Function.java @@ -0,0 +1,31 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package to_array_function; + +import java.util.ArrayList; + +/** + * + * @author Parthkharva + */ +public class To_array_function { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + ArrayList team_member = new ArrayList(); + + team_member.add("Parth"); + team_member.add("Ashish"); + team_member.add("Parit"); + team_member.add("Atmiya"); + team_member.add("Arpit"); + Object[] array_team_member = team_member.toArray(); + System.out.println("Element At Index '0' For Array: "+array_team_member[0]); + System.out.println("HasCode Of The Array: "+array_team_member.hashCode()); + } + +} diff --git a/Parth_Kharva/Data Structure/bfs_traversal.java b/Parth_Kharva/Data Structure/bfs_traversal.java new file mode 100644 index 0000000..46d0276 --- /dev/null +++ b/Parth_Kharva/Data Structure/bfs_traversal.java @@ -0,0 +1,138 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package bfs_traversal; + +import bfs_traversal.Bfs_traversal.Tree.Node; + +/** + * + * @author Parthkharva + */ +public class Bfs_traversal { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Tree tree = new Tree(); + Node root = new Node(50); + tree.insert(root, 12); + tree.insert(root, 1); + tree.insert(root, 26); + tree.insert(root, 10); + tree.insert(root, 2); + tree.insert(root, 62); + tree.insert(root, 152); + tree.insert(root, 129); + tree.insert(root, 17); + tree.insert(root, 100); + + System.out.println("Travers the tree :"); + tree.traversal_inorder(root); + + System.out.println("Travers the tree in pre-order :"); + tree.traversal_preorder(root); + + System.out.println("Travers the tree in post-order :"); + tree.traversal_postorder(root); + + System.out.println("Breadth First Search / Level Order :"); + tree.bfs(root); + } + + public static class Tree { + + static class Node { + + int value; + Node left, right; + + Node(int value) { + this.value = value; + + left = null; + right = null; + } + + } + public void insert(Node node,int value){ + if(valuenode.value){ + if(node.right != null){ + insert(node.right,value); + } + else{ + System.out.println("Insert "+value +" to the right of "+node.value+"."); + node.right = new Node(value); + } + } + } + + public void traversal_inorder(Node node){ + if(node != null){ + traversal_inorder(node.left); + System.out.println(" "+node.value); + traversal_inorder(node.right); + } + } + public void traversal_preorder(Node node){ + if(node != null){ + System.out.println(" "+node.value); + traversal_inorder(node.left); + traversal_inorder(node.right); + } + } + public void traversal_postorder(Node node){ + if(node != null){ + traversal_inorder(node.left); + traversal_inorder(node.right); + System.out.println(" "+node.value); + } + } + + public int height(Node root){ + if(root == null){ + return 0; + } + else{ + int left_height = height(root.left); + int right_height = height(root.right); + if(left_height > right_height){ + return(left_height + 1); + } + else{ + return(right_height + 1); + } + } + } + public void printCurrentlevel(Node root, int level){ + if(root == null){ + return; + } + if(level == 1){ + System.out.println(root.value + " "); + } + else if(level<1){ + printCurrentlevel(root.left,level-1); + printCurrentlevel(root.right,level-1); + } + } + public void bfs(Node root){ + int h = height(root); + for(int i=1; i<=h; i++){ + printCurrentlevel(root,i); + } + } + } + +} diff --git a/Parth_Kharva/Encapsulation_With_Access_Specifer.java b/Parth_Kharva/Encapsulation_With_Access_Specifer.java new file mode 100644 index 0000000..b6addaf --- /dev/null +++ b/Parth_Kharva/Encapsulation_With_Access_Specifer.java @@ -0,0 +1,28 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package encapsulation; + +/** + * + * @author Parthkharva + */ + +class ab{ + private int a = 85; + public int xy = 41; + +} +public class Encapsulation extends ab{ + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Encapsulation obj =new Encapsulation(); + System.out.println("xy="+obj.xy); + System.out.println("a="+obj.a); + } + +} diff --git a/Parth_Kharva/Fiind_Mean_values_using_1D_Array.java b/Parth_Kharva/Fiind_Mean_values_using_1D_Array.java new file mode 100644 index 0000000..c63b29a --- /dev/null +++ b/Parth_Kharva/Fiind_Mean_values_using_1D_Array.java @@ -0,0 +1,26 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package find_mean_with_1d_array; + +/** + * + * @author Parthkharva + */ +public class find_mean_with_1d_array { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + int[] num = new int[2]; + num[0]=34; + num[1]=24; + + int mean = (num[0]+num[1])/2; + + System.out.println("Two array values of mean is : "+mean+"."); + } + +} diff --git a/Parth_Kharva/Inharitance.java b/Parth_Kharva/Inharitance.java new file mode 100644 index 0000000..2c27951 --- /dev/null +++ b/Parth_Kharva/Inharitance.java @@ -0,0 +1,34 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package inharitance; + +/** + * + * @author Parthkharva + */ +class a{ + int x =90; + public void value1(){ + System.out.println("this is a class A"); + } +} +class b extends a{ + public void value2(){ + System.out.println("this is a class B"); + } +} +public class Inharitance extends b{ + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + b obj = new b(); + obj.value1(); + obj.value2(); + System.out.println("class a variable x value is :"+obj.x); + } + +} diff --git a/Parth_Kharva/Lambda/Main_class.java b/Parth_Kharva/Lambda/Main_class.java new file mode 100644 index 0000000..b6f11fa --- /dev/null +++ b/Parth_Kharva/Lambda/Main_class.java @@ -0,0 +1,22 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package lambda; + +/** + * + * @author Parthkharva + */ +public class Lambda { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + practice_1 obj1 =(int a)->{System.out.println(2*a);}; + obj1.abstractfunction(25); + obj1.normalfunction(); + } + +} diff --git a/Parth_Kharva/Lambda/class1.java b/Parth_Kharva/Lambda/class1.java new file mode 100644 index 0000000..1e9ef86 --- /dev/null +++ b/Parth_Kharva/Lambda/class1.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package lambda; + +/** + * + * @author Parthkharva + */ +public interface practice_1 { + void abstractfunction(int a); + default void normalfunction(){ + System.out.println("Hello ji"); + } +} diff --git a/Parth_Kharva/Method_OverLoading.java b/Parth_Kharva/Method_OverLoading.java new file mode 100644 index 0000000..3e8be6e --- /dev/null +++ b/Parth_Kharva/Method_OverLoading.java @@ -0,0 +1,36 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package method_over_loading; + +/** + * + * @author Parthkharva + */ +class math{ + void sum(int i,int j){ + int add = i+j; + System.out.println("Sum of two value is :"+add); + } + void sum(int i,int j,int k){ + int add = i+j+k; + System.out.println("Sum of three value is :"+add); + } + void sum(int i,int j,int k,int l){ + int add = i+j+k+l; + System.out.println("Sum of four value is :"+add); + } +} +public class Method_over_loading { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + math obj =new math(); + obj.sum(45, 78); + obj.sum(45, 91, 12); + obj.sum(82, 1, 0, 99); + } +} diff --git a/Parth_Kharva/Method_Over_Riding.java b/Parth_Kharva/Method_Over_Riding.java new file mode 100644 index 0000000..b045042 --- /dev/null +++ b/Parth_Kharva/Method_Over_Riding.java @@ -0,0 +1,69 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package method_overriding; + +/** + * + * @author Parthkharva + */ +class employee { + + String name; + int age; + double salary; + + void printdata() { + System.out.println("Name : " + name + "\nAge : " + age + "\nSalary : " + salary); + } +} + +class emp1 extends employee { + + String language; + + @Override + void printdata() { + super.printdata(); + System.out.println("Language : "+language); + } +} + +class emp2 extends emp1{ + String database_tool; + void printdata(){ + super.printdata(); + System.out.println("Database tool : "+ database_tool); + } +} + +public class Method_overriding { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + employee obj1 = new employee(); + obj1.name = "Ashish"; + obj1.age = 24; + obj1.salary = 19607.67; + obj1.printdata(); + + emp1 obj2 = new emp1(); + obj2.name = "khyati"; + obj2.age = 21; + obj2.salary = 12987.276; + obj2.language = "Java"; + obj2.printdata(); + + emp2 obj3 = new emp2(); + obj3.name = "Parth"; + obj3.age = 20; + obj3.salary = 14928.78; + obj3.language = "Java"; + obj3.database_tool = "MySQL"; + obj3.printdata(); + } + +} diff --git a/Parth_Kharva/Nested Conditions.java b/Parth_Kharva/Nested Conditions.java new file mode 100644 index 0000000..8448af0 --- /dev/null +++ b/Parth_Kharva/Nested Conditions.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package nested._condition; + +/** + * + * @author Parthkharva + */ +public class Nested_condition { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + String name= "parth",surname="kharva"; + if(name == "parth"){ + if(surname == "jain"){ + System.out.println("your student record is available."); + } + else{ + System.out.println("your student "+name+" "+surname+"'s record is not available."); + } + } + + } + +} diff --git a/Parth_Kharva/Polymorphism/Interface.java b/Parth_Kharva/Polymorphism/Interface.java new file mode 100644 index 0000000..ff99678 --- /dev/null +++ b/Parth_Kharva/Polymorphism/Interface.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package polymorphism; + +/** + * + * @author Parthkharva + */ + interface bank { + float rate_of_interest(); +} diff --git a/Parth_Kharva/Polymorphism/class1.java b/Parth_Kharva/Polymorphism/class1.java new file mode 100644 index 0000000..6f62a94 --- /dev/null +++ b/Parth_Kharva/Polymorphism/class1.java @@ -0,0 +1,25 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package polymorphism; + +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; + +/** + * + * @author Parthkharva + */ + + class pnb implements bank { + + /** + * + * @return + */ + @Override + public float rate_of_interest(){ + return 956.8f; + } +} diff --git a/Parth_Kharva/Polymorphism/class2.java b/Parth_Kharva/Polymorphism/class2.java new file mode 100644 index 0000000..42de96a --- /dev/null +++ b/Parth_Kharva/Polymorphism/class2.java @@ -0,0 +1,15 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package polymorphism; + +/** + * + * @author Parthkharva + */ +public class sbi implements bank { + public float rate_of_interest(){ + return 458.42f; + } +} diff --git a/Parth_Kharva/Polymorphism/main constructer class.java b/Parth_Kharva/Polymorphism/main constructer class.java new file mode 100644 index 0000000..7606f59 --- /dev/null +++ b/Parth_Kharva/Polymorphism/main constructer class.java @@ -0,0 +1,25 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package polymorphism; + +/** + * + * @author Parthkharva + */ + +public class Polymorphism { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + bank obj1 = new pnb(); + bank obj2 = new sbi(); + + System.out.println("ROI :"+obj1.rate_of_interest()); + System.out.println("ROI :"+obj2.rate_of_interest()); + } + +} diff --git a/Parth_Kharva/Read input with 1D Array.java b/Parth_Kharva/Read input with 1D Array.java new file mode 100644 index 0000000..b21e740 --- /dev/null +++ b/Parth_Kharva/Read input with 1D Array.java @@ -0,0 +1,46 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package read_input_with_array; + +import java.util.Scanner; + +/** + * + * @author Parthkharva + */ +public class Read_input_with_array { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("Enter the your required array size:"); + int size = sc.nextInt(); + + //string + String[] array = new String[size]; + System.out.println("Enter String elements of the array : "); + for (int i = 0; i < size; i++) { + array[i] = sc.next(); + } + System.out.println("Your stored array elements are "); + for (int j = 0; j < size; j++) { + System.out.println(array[j]); + } + + //int + int[] arrays = new int[size]; + System.out.println("Enter integer elements of the array : "); + for (int i = 0; i < size; i++) { + arrays[i] = sc.nextInt(); + } + System.out.println("Your stored array elements are "); + for (int j = 0; j < size; j++) { + System.out.println(arrays[j]); + } + } + +} diff --git a/Parth_Kharva/Read_Input with 2d array.java b/Parth_Kharva/Read_Input with 2d array.java new file mode 100644 index 0000000..f7ee088 --- /dev/null +++ b/Parth_Kharva/Read_Input with 2d array.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package read_input_with_2d_array; + +import java.util.Scanner; + +/** + * + * @author Parthkharva + */ +public class Read_input_with_2D_array { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("Enter the your required 2D array Row no:"); + int row = sc.nextInt(); + System.out.println("Enter the your required 2D array column no:"); + int column = sc.nextInt(); + + int[][] array = new int[row][column]; + + System.out.println("Enter integer elements of the array : "); + for (int i = 0; i < row; i++) { + for (int j = 0; j < column; j++) { + array[i][j] = sc.nextInt(); + } + } + + System.out.println("Your stored array elements are "); + for (int i = 0; i < row; i++) { + for (int j = 0; j < column; j++) { + System.out.print(array[i][j]+" "); + } + System.out.println("\n"); + } + } + +} diff --git a/Parth_Kharva/RestFull Web Service/Postman_Result.png b/Parth_Kharva/RestFull Web Service/Postman_Result.png new file mode 100644 index 0000000..85e4cfe Binary files /dev/null and b/Parth_Kharva/RestFull Web Service/Postman_Result.png differ diff --git a/Parth_Kharva/RestFull Web Service/Simple_controller.java b/Parth_Kharva/RestFull Web Service/Simple_controller.java new file mode 100644 index 0000000..9ccc1d4 --- /dev/null +++ b/Parth_Kharva/RestFull Web Service/Simple_controller.java @@ -0,0 +1,12 @@ +package com.java.springboot.test.springbootproject; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +@RestController +public class simple_controller{ + + @RequestMapping("/hello") + public webservice test(){ + return new webservice("Parth Kharva","Navrachana University","BCA","JAVA Intern At Hackveda"); + } +} diff --git a/Parth_Kharva/RestFull Web Service/SpringbootApplication.java b/Parth_Kharva/RestFull Web Service/SpringbootApplication.java new file mode 100644 index 0000000..bfb264c --- /dev/null +++ b/Parth_Kharva/RestFull Web Service/SpringbootApplication.java @@ -0,0 +1,16 @@ +package com.java.springboot.test.springbootproject; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan +public class SpringbootprojectApplication{ + + public static void main(String[] args) { + SpringApplication.run(SpringbootprojectApplication.class, args); + + } + +} diff --git a/Parth_Kharva/RestFull Web Service/web_result.png b/Parth_Kharva/RestFull Web Service/web_result.png new file mode 100644 index 0000000..bfd6c6f Binary files /dev/null and b/Parth_Kharva/RestFull Web Service/web_result.png differ diff --git a/Parth_Kharva/RestFull Web Service/webservice.java b/Parth_Kharva/RestFull Web Service/webservice.java new file mode 100644 index 0000000..d4cd969 --- /dev/null +++ b/Parth_Kharva/RestFull Web Service/webservice.java @@ -0,0 +1,50 @@ +package com.java.springboot.test.springbootproject; + +public class webservice { + + private String name; + private String university; + private String Stream; + private String curren_stateus; + + public webservice(String name, String University,String Stream,String current_Stateus) + { + super(); + this.name = name; + this.university = University; + this.Stream = Stream; + this.curren_stateus = current_Stateus; + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + public String getUniversity() { + return university; + } + + public void setUniversity(String university) { + this.university = university; + } + + public String getStream() { + return Stream; + } + + public void setStream(String stream) { + Stream = stream; + } + + public String getCurren_stateus() { + return curren_stateus; + } + + public void setCurren_stateus(String curren_stateus) { + this.curren_stateus = curren_stateus; + } + +} diff --git a/Parth_Kharva/Spring Framework/main_file.java b/Parth_Kharva/Spring Framework/main_file.java new file mode 100644 index 0000000..6b5947f --- /dev/null +++ b/Parth_Kharva/Spring Framework/main_file.java @@ -0,0 +1,24 @@ +package com.spring_framwork.spring_framwork; + +import java.security.PublicKey; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@RestController +public class SpringFramworkApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringFramworkApplication.class, args); + } + + @GetMapping("/hello") + public String sayhello(@RequestParam(value = "myname", defaultValue = "World")String name) { + return String.format("Hello %s!", name); + } + +} diff --git a/Parth_Kharva/Spring Framework/output with passing parameters.png b/Parth_Kharva/Spring Framework/output with passing parameters.png new file mode 100644 index 0000000..70404a5 Binary files /dev/null and b/Parth_Kharva/Spring Framework/output with passing parameters.png differ diff --git a/Parth_Kharva/Spring Framework/without passing parameters.png b/Parth_Kharva/Spring Framework/without passing parameters.png new file mode 100644 index 0000000..9d5690b Binary files /dev/null and b/Parth_Kharva/Spring Framework/without passing parameters.png differ diff --git a/Parth_Kharva/Spring boot/SpringbootApplication.java b/Parth_Kharva/Spring boot/SpringbootApplication.java new file mode 100644 index 0000000..67c0432 --- /dev/null +++ b/Parth_Kharva/Spring boot/SpringbootApplication.java @@ -0,0 +1,14 @@ +package com.java.springboot.test.springbootproject; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringbootprojectApplication extends simple_controller{ + + public static void main(String[] args) { + SpringApplication.run(SpringbootprojectApplication.class, args); + + } + +} diff --git a/Parth_Kharva/Spring boot/simpe_app_controller.java b/Parth_Kharva/Spring boot/simpe_app_controller.java new file mode 100644 index 0000000..5b1a905 --- /dev/null +++ b/Parth_Kharva/Spring boot/simpe_app_controller.java @@ -0,0 +1,10 @@ +package com.java.springboot.test.springbootproject; + +import org.springframework.web.bind.annotation.RequestMapping; + +public class simple_controller { + @RequestMapping("/hi") + public String test() { + return "Spring boot application using spring initiaizer created by Parth Kharva. "; + } +} diff --git a/Parth_Kharva/Spring_Security/Output.pdf b/Parth_Kharva/Spring_Security/Output.pdf new file mode 100644 index 0000000..f983e2c Binary files /dev/null and b/Parth_Kharva/Spring_Security/Output.pdf differ diff --git a/Parth_Kharva/Spring_Security/Security_config.java b/Parth_Kharva/Spring_Security/Security_config.java new file mode 100644 index 0000000..6b2c7bf --- /dev/null +++ b/Parth_Kharva/Spring_Security/Security_config.java @@ -0,0 +1,52 @@ +package com.spring.security.test.spring_security_test; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.provisioning.InMemoryUserDetailsManager; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +public class Security_config { + @Bean + public PasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } + + @Bean + public UserDetailsService userDetailsService(){ + UserDetails normalUser = User.withUsername("Parth") + .password(passwordEncoder().encode("ParTh")) + .roles("NORMAL") + .build(); + UserDetails adminUser = User.withUsername("Parth125") + .password(passwordEncoder().encode("ParTh")) + .roles("ADMIN") + .build(); + return new InMemoryUserDetailsManager(normalUser,adminUser) ; + } + + + @Bean + public SecurityFilterChain filterchain(HttpSecurity httpsecurity) throws Exception { + httpsecurity.csrf().disable() + .authorizeHttpRequests() + .requestMatchers("/home/admin") + .hasRole("ADMIN") + .requestMatchers("/home/normal") + .hasRole("NORMAL") + .requestMatchers("/home/public") + .permitAll() + .anyRequest() + .authenticated() + .and() + .formLogin(); + return httpsecurity.build(); + } +} + diff --git a/Parth_Kharva/Spring_Security/Simple_Controller.java b/Parth_Kharva/Spring_Security/Simple_Controller.java new file mode 100644 index 0000000..7f2c1ea --- /dev/null +++ b/Parth_Kharva/Spring_Security/Simple_Controller.java @@ -0,0 +1,25 @@ +package com.spring.security.test.spring_security_test; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/home") +public class Simple_Controller { + @GetMapping("/normal") + public ResponseEntity normalUser(){ + return ResponseEntity.ok("Yes, I am normal User"); + } + + @GetMapping("/admin") + public ResponseEntity adminUser(){ + return ResponseEntity.ok("Yes, I am admin User"); + } + + @GetMapping("/public") + public ResponseEntity publicUser(){ + return ResponseEntity.ok("Yes, I am pulic User"); + } +} diff --git a/Parth_Kharva/Spring_Security/SpringSecurityTestApplication.java b/Parth_Kharva/Spring_Security/SpringSecurityTestApplication.java new file mode 100644 index 0000000..3c99e0f --- /dev/null +++ b/Parth_Kharva/Spring_Security/SpringSecurityTestApplication.java @@ -0,0 +1,13 @@ +package com.spring.security.test.spring_security_test; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringSecurityTestApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringSecurityTestApplication.class, args); + } + +} diff --git a/Parth_Kharva/String operations b/Parth_Kharva/String operations new file mode 100644 index 0000000..79776f8 --- /dev/null +++ b/Parth_Kharva/String operations @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package string_operations; + +/** + * + * @author Parthkharva + */ +public class String_operations { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + char x= 'f'; + String name1 = "aNuRaG"; + String name2 = "parth"; + + System.out.println(name1.length()); + System.out.println(name2.charAt(2));// start counting position at 0 + System.out.println(name1.compareTo(name2));//it will compare two strings and givesome asscci value. + System.out.println(name2.strip());// it will remove spaceing(before staring space and after ending space). + + char[] character = name1.toCharArray();// it will convert string value to character value + + for(int i=0;i80 && i<=100){ + System.out.println("Your selected number is in the range of 81 to 100"); + } + else if(i>40 && i<=80){ + System.out.println("Your selected number is in the range of 41 to 80"); + } + if(i>0 && i<=40){ + System.out.println("Your selected number is in the range of 1 to 40"); + } + else if(i>100){ + System.out.println("Your selected number is above 100 "); + } + } + +} diff --git a/Parth_Kharva/data type and operaters b/Parth_Kharva/data type and operaters new file mode 100644 index 0000000..9e0867b --- /dev/null +++ b/Parth_Kharva/data type and operaters @@ -0,0 +1,59 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package javaapplication1; + +import static jdk.nashorn.api.scripting.ScriptUtils.convert; + +/** + * + * @author Parthkharva + */ +public class JavaApplication1 { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + int a = 10; + int b = 52; + float x= 123.4556655f; + System.out.println(x); + + double dd = 456/45; + System.out.println(dd); + + String c = "parth"; + String name = null; + System.out.println("name:"+c+" : "+name); + + int d =++b; + System.out.println(d); + + int e =b++; + System.out.println(e); + + int f = a--; + System.out.println(f); + + int g = --a; + System.out.println(g); + + int h = a+b; + System.out.println(h); + + int i = a-b; + System.out.println(f); + + int j = a*b; + System.out.println(j); + + int k = a/b; + System.out.println(k); + + boolean bl = true; + System.out.println(bl); + System.out.println(!bl); + } +} diff --git a/Parth_Kharva/do_while loop.java b/Parth_Kharva/do_while loop.java new file mode 100644 index 0000000..7fae7e5 --- /dev/null +++ b/Parth_Kharva/do_while loop.java @@ -0,0 +1,25 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package do_while; + +/** + * + * @author Parthkharva + */ +public class Do_while { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + int i = 1; + do{ + System.out.println(i); + i++; + } + while(i<=10); + } + +} diff --git a/Parth_Kharva/for_loop.java b/Parth_Kharva/for_loop.java new file mode 100644 index 0000000..8267c7d --- /dev/null +++ b/Parth_Kharva/for_loop.java @@ -0,0 +1,26 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package for_loop; + +/** + * + * @author Parthkharva + */ +public class For_loop { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + + for(int i= 1;i<=5;i++){ + for(int j= 1;j<=10;j++){ + System.out.println("value of i:"+i+"value of j:"+j+"."); + } + System.out.print("\n"); + } + } + +} diff --git a/Parth_Kharva/jshell.java b/Parth_Kharva/jshell.java new file mode 100644 index 0000000..46de38b --- /dev/null +++ b/Parth_Kharva/jshell.java @@ -0,0 +1,65 @@ +| Welcome to JShell -- Version 11.0.10 +| For an introduction type: /help intro + +jshell> String print(String a){return a+a;} +| created method print(String) + +jshell> print("Parth") +$2 ==> "ParthParth" + +jshell> int sum(int x, int y){return x*y;} +| created method sum(int,int) + +jshell> sum(45,21) +$4 ==> 945 + +jshell> double volume(double radius){ return 4.0/7.6 * 3.14 * 89*45*2 * radius;} +| created method volume(double) + +jshell> volume(8); +$6 ==> 105900.63157894736 + +jshell> /vars +| String $2 = "ParthParth" +| int $4 = 945 +| double $6 = 105900.63157894736 + +jshell> /methods +| String print(String) +| int sum(int,int) +| double volume(double) + +jshell> /list + + 1 : String print(String a){return a+a;} + 2 : print("Parth") + 3 : int sum(int x, int y){return x*y;} + 4 : sum(45,21) + 5 : double volume(double radius){ return 4.0/7.6 * 3.14 * 89*45*2 * radius;} + 6 : volume(8); + +jshell> /list -all + + s1 : import java.io.*; + s2 : import java.math.*; + s3 : import java.net.*; + s4 : import java.nio.file.*; + s5 : import java.util.*; + s6 : import java.util.concurrent.*; + s7 : import java.util.function.*; + s8 : import java.util.prefs.*; + s9 : import java.util.regex.*; + s10 : import java.util.stream.*; + 1 : String print(String a){return a+a;} + 2 : print("Parth") + 3 : int sum(int x, int y){return x*y;} + 4 : sum(45,21) + 5 : double volume(double radius){ return 4.0/7.6 * 3.14 * 89*45*2 * radius;} + 6 : volume(8); + +jshell> int x = 78; +x ==> 78 + jshell> +jshell> +jshell> String x +x ==> null diff --git a/Parth_Kharva/while loop.java b/Parth_Kharva/while loop.java new file mode 100644 index 0000000..95c0f8f --- /dev/null +++ b/Parth_Kharva/while loop.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package while_loop; + +/** + * + * @author Parthkharva + */ +public class While_loop { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + int i=1, j=1; + while(i<=10){ + while(j<=9){ + System.out.println(j); + j++; + } + i++; + j=1; + System.out.print("\n"); + } + } + +}