From 11b07937371351eec3d234d4b3143bd4ae918a62 Mon Sep 17 00:00:00 2001 From: MrAkashKumar Date: Sun, 11 Oct 2020 12:21:53 +0530 Subject: [PATCH] Programming Java Concept --- .../.classpath | 0 .../.project | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../com/akash/arrayList/AddMultipleList.java | 0 .../akash/arrayList/ArrayListContains.java | 0 .../com/akash/arrayList/ArrayListDemo.java | 0 .../com/akash/arrayList/ArrayListExample.java | 0 .../src/com/akash/arrayList/ArraySubList.java | 0 .../com/akash/arrayList/CheckEmptyList.java | 0 .../akash/arrayList/ConvertArrayToVector.java | 0 .../com/akash/arrayList/RemoveDuplicates.java | 0 .../akash/arrayList/RetainAllCollection.java | 0 .../akash/arrayList/SwapArrayListExample.java | 0 .../src/com/akash/arrayList/ToArrayDemo.java | 0 .../arrayListException/ArrayExample.java | 0 .../ArrayListConcurrentModification.java | 0 .../ConcurrentSkipListDemo.java | 26 ++++++ .../collectionExample/ExceptionDemo.java | 14 ++++ .../collectionExample/HashMapExample.java | 36 +++++++++ .../akash/collectionExample/LinkListDemo.java | 21 +++++ .../akash/collectionss/ComparaterTest.java | 38 +++++++++ .../com/akash/collectionss/StringSort.java | 14 ++++ .../src/com/akash/colonable/Runner.java | 0 .../src/com/akash/colonable/Test.java | 0 .../src/com/akash/colonable/Test2.java | 0 .../comparable/CollectionsSortComparable.java | 0 .../com/akash/comparable/ComparableDemo.java | 0 .../akash/comparable/ComparableObject.java | 0 .../src/com/akash/comparable/Employee.java | 0 .../akash/comparator/ComparatorExample.java | 0 .../src/com/akash/comparator/Employee.java | 0 .../ConcurrencyHashMapDemo.java | 0 .../concurrencyhashMap/OccureneceNumber.java | 0 .../CopyOnWriteArrayThreadDemo.java | 32 ++++++++ .../src/com/akash/hashmap/HashMapADemo.java | 0 .../src/com/akash/hashmap/HashMapDemo.java | 0 .../src/com/akash/hashmap/HashMapExample.java | 0 .../src/com/akash/hashset/ConvertHashSet.java | 0 .../src/com/akash/hashset/HashSetDemo.java | 0 .../src/com/akash/hashtable/HashTable.java | 0 .../linkedhashMap/LinkedHashMapDemo.java | 0 .../linkedhashSet/LinkedHashSetDemo.java | 0 .../com/akash/linklist/LinkedListDemo.java | 0 .../com/akash/linklist/SortLinkedList.java | 0 .../com/akash/list/ArrayListCollection.java | 0 .../src/com/akash/list/ArrayListDemo.java | 0 .../com/akash/mapi/CharCountOccurance.java | 0 .../com/akash/mapi/IteratorUsingKeySet.java | 0 .../src/com/akash/mapi/ItertorMapDemo.java | 0 .../src/com/akash/mapi/ItratingMapEntry.java | 0 .../src/com/akash/mapi/TreeMapDemo.java | 0 .../src/com/akash/set/TreeSetExample.java | 0 .../akash/swaping/SwapingwithoutThird.java | 25 ++++++ .../src/com/akash/swaping/SwappingString.java | 21 +++++ .../src/com/akash/treeMap/TreeMapDemo.java | 0 .../src/com/akash/treeMap/TreeMapReverse.java | 0 .../src/com/akash/treeSet/TreeSetDemo.java | 0 DataStructure/.classpath | 6 ++ DataStructure/.project | 17 ++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../akash/binarySearch/BinaryRecursion.java | 25 ++++++ .../BinaryTreeUsingRecursion.java | 21 +++++ .../circularLinked/CreateCircularList.java | 47 +++++++++++ .../dataStructure/Alphabetical_Order.java | 29 +++++++ .../com/akash/dataStructure/InsertArray.java | 30 +++++++ .../dataStructure/LinkedListInternal.java | 39 +++++++++ .../akash/dataStructure/LinkedListLoop.java | 37 +++++++++ .../dataStructure/NonRepeatedElement.java | 34 ++++++++ .../com/akash/dataStructure/SortingAsc.java | 35 ++++++++ .../com/akash/dataStructure/SortingDemo.java | 38 +++++++++ .../com/akash/dataStructure/SplitArray.java | 44 ++++++++++ .../com/akash/insertion/InsertLinkedList.java | 57 +++++++++++++ .../com/akash/insertion/InsertionSort.java | 27 +++++++ .../src/com/akash/mergeList/MergeSort.java | 81 +++++++++++++++++++ .../middleList/FindMiddleLinkedList.java | 46 +++++++++++ .../akash/reverseLinked/ReverseLinked.java | 57 +++++++++++++ .../reverseLinked/ReverseLinkedList.java | 57 +++++++++++++ Exception/.classpath | 6 ++ Exception/.project | 17 ++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../com/akash/ExceptionThrow/ThrowExcept.java | 25 ++++++ .../akash/ExceptionThrow/ThrowsException.java | 25 ++++++ .../arithmatic/ArithmaticExceptionDemo.java | 22 +++++ .../akash/calculatorException/Calculator.java | 15 ++++ .../com/akash/calculatorException/Runner.java | 20 +++++ .../exceptionBlock/ExceptionChainingDmo.java | 22 +++++ .../akash/exceptionBlock/ExceptionDemo.java | 28 +++++++ .../exceptionLogic/ExceptionIncrement.java | 25 ++++++ .../com/akash/exceptions/ExceptionDemo.java | 41 ++++++++++ .../akash/exceptions/ExceptionExample.java | 24 ++++++ .../akash/exceptions/TryCatchException.java | 23 ++++++ .../finalException/FinalVariableExample.java | 12 +++ .../finallizeExample/FinalizeExample.java | 26 ++++++ .../FinallyExampleException.java | 21 +++++ .../com/akash/throwsDemo/ExceptionDemo.java | 32 ++++++++ ImportantLogical/.classpath | 6 ++ ImportantLogical/.project | 17 ++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../src/com/akash/abstractfinal/Bank.java | 8 ++ .../src/com/akash/abstractfinal/Sbi.java | 8 ++ .../instanceInitail/ConstructorInitial.java | 38 +++++++++ .../akash/instanceInitail/InstanceBlock.java | 31 +++++++ .../akash/instanceInitail/StaticBlock.java | 26 ++++++ .../staticblock/MultipleStaticBlockdemo.java | 26 ++++++ .../staticblock/StaticBlockVariable.java | 33 ++++++++ .../com/akash/staticblock/StaticVariable.java | 22 +++++ .../src/com/akash/staticblock/TestDemo.java | 6 ++ .../src/com/akash/tryCatch/FinallyBlock.java | 23 ++++++ ImportantProgram/.classpath | 6 ++ ImportantProgram/.project | 17 ++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../com/akash/cloneDemo/CloneDemoExample.java | 24 ++++++ .../src/com/akash/enumDemo/Element.java | 31 +++++++ .../src/com/akash/enumExample/Account.java | 11 +++ .../src/com/akash/enumExample/Accounts.java | 13 +++ .../src/com/akash/enums/EnumExample.java | 11 +++ .../src/com/akash/enums/Mobile.java | 8 ++ .../hashCodeAndEquals/HashCodeAndEquals.java | 65 +++++++++++++++ .../com/akash/itertorDemo/ItertorDemo.java | 41 ++++++++++ .../com/akash/serializations/ClientTest.java | 51 ++++++++++++ .../com/akash/serializations/Employee.java | 33 ++++++++ .../src/com/akash/serilization/Demo.java | 34 ++++++++ .../src/com/akash/serilization/Employee.java | 22 +++++ .../StringClassImmutableHashCode.java | 20 +++++ .../akash/validateEmail/EmailValidate.java | 34 ++++++++ .../com/akash/eightJava/DefaultAExample.java | 9 +++ .../com/akash/eightJava/DefaultBExample.java | 15 ++++ .../src/com/akash/eightJava/Example.java | 17 ++++ .../src/com/akash/eightJava/MainRunner.java | 16 ++++ MultithreadingExample/.classpath | 6 ++ MultithreadingExample/.project | 17 ++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../akash/begin/MultiThreadingExtending.java | 17 ++++ .../src/com/akash/begin/ThreadImplement.java | 15 ++++ .../akash/classLevelLock/ClassLevelBlock.java | 11 +++ .../akash/classLevelLock/ClassLevelLock.java | 8 ++ .../classLevelLock/ClassLevelinstance.java | 14 ++++ .../src/com/akash/deadLock/AvoidDeadLock.java | 27 +++++++ .../com/akash/deadLock/ResultDeadLock.java | 26 ++++++ .../src/com/akash/exception/X.java | 23 ++++++ .../src/com/akash/lock/ObjectLock.java | 8 ++ .../src/com/akash/lock/ObjectLockOther.java | 18 +++++ .../com/akash/lock/ObjectLockThreadSafe.java | 10 +++ OppsConcepts/.classpath | 6 ++ OppsConcepts/.project | 17 ++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../com/akash/abstractClass/AbstractDemo.java | 8 ++ .../abstractClass/ContainConstructor.java | 9 +++ .../src/com/akash/abstractfinal/Bank.java | 8 ++ .../src/com/akash/abstractfinal/Sbi.java | 8 ++ .../src/com/akash/abstraction/Circle.java | 26 ++++++ .../src/com/akash/abstraction/Rectangle.java | 28 +++++++ .../src/com/akash/abstraction/Runner.java | 16 ++++ .../src/com/akash/abstraction/Shape.java | 21 +++++ OppsConcepts/src/com/akash/abstracts/Abc.java | 10 +++ OppsConcepts/src/com/akash/abstracts/Bcd.java | 16 ++++ .../akash/equalsHashCode/TestHashEquals.java | 26 ++++++ .../hashCodeAndEquals/HashCodeAndEquals.java | 65 +++++++++++++++ .../immutableClass/FinalClassExample.java | 26 ++++++ OppsConcepts/src/com/akash/inher/Animal.java | 9 +++ OppsConcepts/src/com/akash/inher/Dog.java | 12 +++ OppsConcepts/src/com/akash/inher/Runner.java | 28 +++++++ .../src/com/akash/inheriDemo/Child.java | 12 +++ .../src/com/akash/inheriDemo/MyInterface.java | 24 ++++++ .../src/com/akash/inheriDemo/Parent.java | 8 ++ .../src/com/akash/inheriDemo/Runner.java | 32 ++++++++ .../src/com/akash/inheriDemo/SubChild.java | 17 ++++ .../src/com/akash/inheriThrow/Abc.java | 9 +++ .../src/com/akash/inheriThrow/Bcd.java | 17 ++++ .../src/com/akash/inheriThrow/Runner.java | 10 +++ .../com/akash/inheritanceDemo/ChildDemo.java | 8 ++ .../inheritanceDemo/InheritanceDemo.java | 13 +++ .../src/com/akash/inheritanceDemo/Runner.java | 15 ++++ .../src/com/akash/inheritanceExam/Child.java | 10 +++ .../src/com/akash/inheritanceExam/Parent.java | 14 ++++ .../src/com/akash/inheritanceExam/Runner.java | 27 +++++++ .../src/com/akash/inheritancestatic/A.java | 16 ++++ .../src/com/akash/inheritancestatic/B.java | 16 ++++ .../akash/inheritancestatic/MainMethod.java | 18 +++++ .../src/com/akash/inhertanceDemo/DemoA.java | 9 +++ .../src/com/akash/inhertanceDemo/DemoB.java | 9 +++ .../src/com/akash/inhertanceDemo/Runner.java | 10 +++ .../instanceInitail/ConstructorInitial.java | 38 +++++++++ .../akash/instanceInitail/InstanceBlock.java | 31 +++++++ .../akash/instanceInitail/StaticBlock.java | 26 ++++++ .../src/com/akash/interfaceClass/Bank.java | 19 +++++ .../src/com/akash/interfaceClass/HDCF.java | 17 ++++ .../src/com/akash/interfaceClass/ICICI.java | 17 ++++ .../src/com/akash/interfaceClass/RBI.java | 7 ++ .../src/com/akash/interfaceClass/SBI.java | 17 ++++ OppsConcepts/src/com/akash/logic/A.java | 35 ++++++++ OppsConcepts/src/com/akash/logic/B.java | 19 +++++ .../src/com/akash/logic/Employee.java | 49 +++++++++++ OppsConcepts/src/com/akash/logic/Runner.java | 15 ++++ OppsConcepts/src/com/akash/logical/A.java | 11 +++ OppsConcepts/src/com/akash/logical/B.java | 11 +++ OppsConcepts/src/com/akash/logical/Demo.java | 24 ++++++ .../src/com/akash/logical/DemoProgram.java | 12 +++ OppsConcepts/src/com/akash/logical/List.java | 12 +++ .../akash/methodOverloadingE/AddResult.java | 26 ++++++ .../com/akash/methodOverloadingE/Runner.java | 15 ++++ .../com/akash/overridingMethodExam/Base.java | 17 ++++ .../akash/overridingMethodExam/Derived.java | 12 +++ .../akash/overridingMethodExam/Runner.java | 14 ++++ .../com/akash/runtimepolymorphism/Audi.java | 8 ++ .../com/akash/runtimepolymorphism/Car.java | 8 ++ .../com/akash/runtimepolymorphism/Runner.java | 11 +++ .../staticblock/MultipleStaticBlockdemo.java | 26 ++++++ .../staticblock/StaticBlockVariable.java | 33 ++++++++ .../com/akash/staticblock/StaticVariable.java | 22 +++++ .../src/com/akash/staticblock/TestDemo.java | 6 ++ .../StringClassImmutableHashCode.java | 20 +++++ .../src/com/akash/stringdemo/Child.java | 9 +++ .../src/com/akash/stringdemo/ConctTest.java | 21 +++++ .../com/akash/stringdemo/ExceptionTest.java | 19 +++++ .../src/com/akash/stringdemo/MainClassPC.java | 10 +++ .../src/com/akash/stringdemo/Parent.java | 9 +++ Program/src/com/akash/convertdata/Abc.java | 31 +++++++ .../com/akash/convertdata/ConvertData.java | 39 +++++++++ .../src/com/akash/program/AnagramProgram.java | 40 +++++++++ .../src/com/akash/program/BinarySearch.java | 38 +++++++++ .../src/com/akash/program/CheckDigitOnly.java | 26 ++++++ Program/src/com/akash/program/ClassTest1.java | 13 +++ .../src/com/akash/program/CountOddSum.java | 30 +++++++ .../FindDubplicationCharFromString.java | 34 ++++++++ .../FirstSecondLargestNumInAnArray.java | 5 ++ .../akash/program/NoDuplicationProgram.java | 38 +++++++++ .../src/com/akash/program/PalidromeDemo.java | 29 +++++++ .../src/com/akash/program/ReverseArray.java | 36 +++++++++ Program/src/com/akash/program/Runner.java | 16 ++++ .../akash/programming/ArmstrongNumber.java | 28 +++++++ .../com/akash/programming/CloneExample.java | 27 +++++++ .../programming/ContainsOnlyLetters.java | 29 +++++++ .../com/akash/programming/CountFrequency.java | 28 +++++++ .../src/com/akash/programming/Factorial.java | 21 +++++ .../akash/programming/FibonanciSeries.java | 16 ++++ .../com/akash/programming/FinalCountWord.java | 32 ++++++++ .../akash/programming/FindLargeNumber.java | 26 ++++++ .../akash/programming/FindSecondLargest.java | 34 ++++++++ .../akash/programming/FindUniqueElement.java | 29 +++++++ .../akash/programming/FirstAndLastGet.java | 29 +++++++ .../com/akash/programming/IteratingDemo.java | 36 +++++++++ .../com/akash/programming/MaxDifference.java | 31 +++++++ .../akash/programming/PalidromeNumber.java | 25 ++++++ .../com/akash/programming/PrimeNumber.java | 23 ++++++ .../com/akash/programming/PushZeroToEnd.java | 28 +++++++ .../akash/programming/RemoveWhiteSpace.java | 22 +++++ .../com/akash/programming/ReplaceMethod.java | 47 +++++++++++ .../akash/uniquelement/FindUniqueElement.java | 34 ++++++++ designPattern/.classpath | 6 ++ designPattern/.project | 17 ++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ designPattern/Singleton.java | 18 +++++ designPattern/SingletonDemo.java | 18 +++++ .../com/akash/designPattern/Singleton.java | 18 +++++ .../akash/designPattern/SingletonDemo.java | 18 +++++ .../src/com/akash/factorypattern/Android.java | 0 .../src/com/akash/factorypattern/IOS.java | 0 .../src/com/akash/factorypattern/OS.java | 0 .../OperatingSystemFactory.java | 0 .../factorypattern/RunnerFactoryDesign.java | 0 .../src/com/akash/factorypattern/Window.java | 0 .../src/com/akash/singleton/RunnerClass.java | 11 +++ .../src/com/akash/singleton/SingletonApp.java | 21 +++++ 264 files changed, 4663 insertions(+) rename {ImportantCollectionApp => CollectionProgram}/.classpath (100%) rename {ImportantCollectionApp => CollectionProgram}/.project (100%) rename {ImportantCollectionApp => CollectionProgram}/.settings/org.eclipse.jdt.core.prefs (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/AddMultipleList.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/ArrayListContains.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/ArrayListDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/ArrayListExample.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/ArraySubList.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/CheckEmptyList.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/ConvertArrayToVector.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/RemoveDuplicates.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/RetainAllCollection.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/SwapArrayListExample.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayList/ToArrayDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayListException/ArrayExample.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/arrayListException/ArrayListConcurrentModification.java (100%) create mode 100644 CollectionProgram/src/com/akash/collectionExample/ConcurrentSkipListDemo.java create mode 100644 CollectionProgram/src/com/akash/collectionExample/ExceptionDemo.java create mode 100644 CollectionProgram/src/com/akash/collectionExample/HashMapExample.java create mode 100644 CollectionProgram/src/com/akash/collectionExample/LinkListDemo.java create mode 100644 CollectionProgram/src/com/akash/collectionss/ComparaterTest.java create mode 100644 CollectionProgram/src/com/akash/collectionss/StringSort.java rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/colonable/Runner.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/colonable/Test.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/colonable/Test2.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/comparable/CollectionsSortComparable.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/comparable/ComparableDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/comparable/ComparableObject.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/comparable/Employee.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/comparator/ComparatorExample.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/comparator/Employee.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/concurrencyhashMap/ConcurrencyHashMapDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/concurrencyhashMap/OccureneceNumber.java (100%) create mode 100644 CollectionProgram/src/com/akash/copyonWriteArrayList/CopyOnWriteArrayThreadDemo.java rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/hashmap/HashMapADemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/hashmap/HashMapDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/hashmap/HashMapExample.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/hashset/ConvertHashSet.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/hashset/HashSetDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/hashtable/HashTable.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/linkedhashMap/LinkedHashMapDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/linkedhashSet/LinkedHashSetDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/linklist/LinkedListDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/linklist/SortLinkedList.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/list/ArrayListCollection.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/list/ArrayListDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/mapi/CharCountOccurance.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/mapi/IteratorUsingKeySet.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/mapi/ItertorMapDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/mapi/ItratingMapEntry.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/mapi/TreeMapDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/set/TreeSetExample.java (100%) create mode 100644 CollectionProgram/src/com/akash/swaping/SwapingwithoutThird.java create mode 100644 CollectionProgram/src/com/akash/swaping/SwappingString.java rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/treeMap/TreeMapDemo.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/treeMap/TreeMapReverse.java (100%) rename {ImportantCollectionApp => CollectionProgram}/src/com/akash/treeSet/TreeSetDemo.java (100%) create mode 100644 DataStructure/.classpath create mode 100644 DataStructure/.project create mode 100644 DataStructure/.settings/org.eclipse.jdt.core.prefs create mode 100644 DataStructure/src/com/akash/binarySearch/BinaryRecursion.java create mode 100644 DataStructure/src/com/akash/binaryTreeRecursion/BinaryTreeUsingRecursion.java create mode 100644 DataStructure/src/com/akash/circularLinked/CreateCircularList.java create mode 100644 DataStructure/src/com/akash/dataStructure/Alphabetical_Order.java create mode 100644 DataStructure/src/com/akash/dataStructure/InsertArray.java create mode 100644 DataStructure/src/com/akash/dataStructure/LinkedListInternal.java create mode 100644 DataStructure/src/com/akash/dataStructure/LinkedListLoop.java create mode 100644 DataStructure/src/com/akash/dataStructure/NonRepeatedElement.java create mode 100644 DataStructure/src/com/akash/dataStructure/SortingAsc.java create mode 100644 DataStructure/src/com/akash/dataStructure/SortingDemo.java create mode 100644 DataStructure/src/com/akash/dataStructure/SplitArray.java create mode 100644 DataStructure/src/com/akash/insertion/InsertLinkedList.java create mode 100644 DataStructure/src/com/akash/insertion/InsertionSort.java create mode 100644 DataStructure/src/com/akash/mergeList/MergeSort.java create mode 100644 DataStructure/src/com/akash/middleList/FindMiddleLinkedList.java create mode 100644 DataStructure/src/com/akash/reverseLinked/ReverseLinked.java create mode 100644 DataStructure/src/com/akash/reverseLinked/ReverseLinkedList.java create mode 100644 Exception/.classpath create mode 100644 Exception/.project create mode 100644 Exception/.settings/org.eclipse.jdt.core.prefs create mode 100644 Exception/src/com/akash/ExceptionThrow/ThrowExcept.java create mode 100644 Exception/src/com/akash/ExceptionThrow/ThrowsException.java create mode 100644 Exception/src/com/akash/arithmatic/ArithmaticExceptionDemo.java create mode 100644 Exception/src/com/akash/calculatorException/Calculator.java create mode 100644 Exception/src/com/akash/calculatorException/Runner.java create mode 100644 Exception/src/com/akash/exceptionBlock/ExceptionChainingDmo.java create mode 100644 Exception/src/com/akash/exceptionBlock/ExceptionDemo.java create mode 100644 Exception/src/com/akash/exceptionLogic/ExceptionIncrement.java create mode 100644 Exception/src/com/akash/exceptions/ExceptionDemo.java create mode 100644 Exception/src/com/akash/exceptions/ExceptionExample.java create mode 100644 Exception/src/com/akash/exceptions/TryCatchException.java create mode 100644 Exception/src/com/akash/finalException/FinalVariableExample.java create mode 100644 Exception/src/com/akash/finallizeExample/FinalizeExample.java create mode 100644 Exception/src/com/akash/finallyException/FinallyExampleException.java create mode 100644 Exception/src/com/akash/throwsDemo/ExceptionDemo.java create mode 100644 ImportantLogical/.classpath create mode 100644 ImportantLogical/.project create mode 100644 ImportantLogical/.settings/org.eclipse.jdt.core.prefs create mode 100644 ImportantLogical/src/com/akash/abstractfinal/Bank.java create mode 100644 ImportantLogical/src/com/akash/abstractfinal/Sbi.java create mode 100644 ImportantLogical/src/com/akash/instanceInitail/ConstructorInitial.java create mode 100644 ImportantLogical/src/com/akash/instanceInitail/InstanceBlock.java create mode 100644 ImportantLogical/src/com/akash/instanceInitail/StaticBlock.java create mode 100644 ImportantLogical/src/com/akash/staticblock/MultipleStaticBlockdemo.java create mode 100644 ImportantLogical/src/com/akash/staticblock/StaticBlockVariable.java create mode 100644 ImportantLogical/src/com/akash/staticblock/StaticVariable.java create mode 100644 ImportantLogical/src/com/akash/staticblock/TestDemo.java create mode 100644 ImportantLogical/src/com/akash/tryCatch/FinallyBlock.java create mode 100644 ImportantProgram/.classpath create mode 100644 ImportantProgram/.project create mode 100644 ImportantProgram/.settings/org.eclipse.jdt.core.prefs create mode 100644 ImportantProgram/src/com/akash/cloneDemo/CloneDemoExample.java create mode 100644 ImportantProgram/src/com/akash/enumDemo/Element.java create mode 100644 ImportantProgram/src/com/akash/enumExample/Account.java create mode 100644 ImportantProgram/src/com/akash/enumExample/Accounts.java create mode 100644 ImportantProgram/src/com/akash/enums/EnumExample.java create mode 100644 ImportantProgram/src/com/akash/enums/Mobile.java create mode 100644 ImportantProgram/src/com/akash/hashCodeAndEquals/HashCodeAndEquals.java create mode 100644 ImportantProgram/src/com/akash/itertorDemo/ItertorDemo.java create mode 100644 ImportantProgram/src/com/akash/serializations/ClientTest.java create mode 100644 ImportantProgram/src/com/akash/serializations/Employee.java create mode 100644 ImportantProgram/src/com/akash/serilization/Demo.java create mode 100644 ImportantProgram/src/com/akash/serilization/Employee.java create mode 100644 ImportantProgram/src/com/akash/stringImmutable/StringClassImmutableHashCode.java create mode 100644 ImportantProgram/src/com/akash/validateEmail/EmailValidate.java create mode 100644 Java8Program/src/com/akash/eightJava/DefaultAExample.java create mode 100644 Java8Program/src/com/akash/eightJava/DefaultBExample.java create mode 100644 Java8Program/src/com/akash/eightJava/Example.java create mode 100644 Java8Program/src/com/akash/eightJava/MainRunner.java create mode 100644 MultithreadingExample/.classpath create mode 100644 MultithreadingExample/.project create mode 100644 MultithreadingExample/.settings/org.eclipse.jdt.core.prefs create mode 100644 MultithreadingExample/src/com/akash/begin/MultiThreadingExtending.java create mode 100644 MultithreadingExample/src/com/akash/begin/ThreadImplement.java create mode 100644 MultithreadingExample/src/com/akash/classLevelLock/ClassLevelBlock.java create mode 100644 MultithreadingExample/src/com/akash/classLevelLock/ClassLevelLock.java create mode 100644 MultithreadingExample/src/com/akash/classLevelLock/ClassLevelinstance.java create mode 100644 MultithreadingExample/src/com/akash/deadLock/AvoidDeadLock.java create mode 100644 MultithreadingExample/src/com/akash/deadLock/ResultDeadLock.java create mode 100644 MultithreadingExample/src/com/akash/exception/X.java create mode 100644 MultithreadingExample/src/com/akash/lock/ObjectLock.java create mode 100644 MultithreadingExample/src/com/akash/lock/ObjectLockOther.java create mode 100644 MultithreadingExample/src/com/akash/lock/ObjectLockThreadSafe.java create mode 100644 OppsConcepts/.classpath create mode 100644 OppsConcepts/.project create mode 100644 OppsConcepts/.settings/org.eclipse.jdt.core.prefs create mode 100644 OppsConcepts/src/com/akash/abstractClass/AbstractDemo.java create mode 100644 OppsConcepts/src/com/akash/abstractClass/ContainConstructor.java create mode 100644 OppsConcepts/src/com/akash/abstractfinal/Bank.java create mode 100644 OppsConcepts/src/com/akash/abstractfinal/Sbi.java create mode 100644 OppsConcepts/src/com/akash/abstraction/Circle.java create mode 100644 OppsConcepts/src/com/akash/abstraction/Rectangle.java create mode 100644 OppsConcepts/src/com/akash/abstraction/Runner.java create mode 100644 OppsConcepts/src/com/akash/abstraction/Shape.java create mode 100644 OppsConcepts/src/com/akash/abstracts/Abc.java create mode 100644 OppsConcepts/src/com/akash/abstracts/Bcd.java create mode 100644 OppsConcepts/src/com/akash/equalsHashCode/TestHashEquals.java create mode 100644 OppsConcepts/src/com/akash/hashCodeAndEquals/HashCodeAndEquals.java create mode 100644 OppsConcepts/src/com/akash/immutableClass/FinalClassExample.java create mode 100644 OppsConcepts/src/com/akash/inher/Animal.java create mode 100644 OppsConcepts/src/com/akash/inher/Dog.java create mode 100644 OppsConcepts/src/com/akash/inher/Runner.java create mode 100644 OppsConcepts/src/com/akash/inheriDemo/Child.java create mode 100644 OppsConcepts/src/com/akash/inheriDemo/MyInterface.java create mode 100644 OppsConcepts/src/com/akash/inheriDemo/Parent.java create mode 100644 OppsConcepts/src/com/akash/inheriDemo/Runner.java create mode 100644 OppsConcepts/src/com/akash/inheriDemo/SubChild.java create mode 100644 OppsConcepts/src/com/akash/inheriThrow/Abc.java create mode 100644 OppsConcepts/src/com/akash/inheriThrow/Bcd.java create mode 100644 OppsConcepts/src/com/akash/inheriThrow/Runner.java create mode 100644 OppsConcepts/src/com/akash/inheritanceDemo/ChildDemo.java create mode 100644 OppsConcepts/src/com/akash/inheritanceDemo/InheritanceDemo.java create mode 100644 OppsConcepts/src/com/akash/inheritanceDemo/Runner.java create mode 100644 OppsConcepts/src/com/akash/inheritanceExam/Child.java create mode 100644 OppsConcepts/src/com/akash/inheritanceExam/Parent.java create mode 100644 OppsConcepts/src/com/akash/inheritanceExam/Runner.java create mode 100644 OppsConcepts/src/com/akash/inheritancestatic/A.java create mode 100644 OppsConcepts/src/com/akash/inheritancestatic/B.java create mode 100644 OppsConcepts/src/com/akash/inheritancestatic/MainMethod.java create mode 100644 OppsConcepts/src/com/akash/inhertanceDemo/DemoA.java create mode 100644 OppsConcepts/src/com/akash/inhertanceDemo/DemoB.java create mode 100644 OppsConcepts/src/com/akash/inhertanceDemo/Runner.java create mode 100644 OppsConcepts/src/com/akash/instanceInitail/ConstructorInitial.java create mode 100644 OppsConcepts/src/com/akash/instanceInitail/InstanceBlock.java create mode 100644 OppsConcepts/src/com/akash/instanceInitail/StaticBlock.java create mode 100644 OppsConcepts/src/com/akash/interfaceClass/Bank.java create mode 100644 OppsConcepts/src/com/akash/interfaceClass/HDCF.java create mode 100644 OppsConcepts/src/com/akash/interfaceClass/ICICI.java create mode 100644 OppsConcepts/src/com/akash/interfaceClass/RBI.java create mode 100644 OppsConcepts/src/com/akash/interfaceClass/SBI.java create mode 100644 OppsConcepts/src/com/akash/logic/A.java create mode 100644 OppsConcepts/src/com/akash/logic/B.java create mode 100644 OppsConcepts/src/com/akash/logic/Employee.java create mode 100644 OppsConcepts/src/com/akash/logic/Runner.java create mode 100644 OppsConcepts/src/com/akash/logical/A.java create mode 100644 OppsConcepts/src/com/akash/logical/B.java create mode 100644 OppsConcepts/src/com/akash/logical/Demo.java create mode 100644 OppsConcepts/src/com/akash/logical/DemoProgram.java create mode 100644 OppsConcepts/src/com/akash/logical/List.java create mode 100644 OppsConcepts/src/com/akash/methodOverloadingE/AddResult.java create mode 100644 OppsConcepts/src/com/akash/methodOverloadingE/Runner.java create mode 100644 OppsConcepts/src/com/akash/overridingMethodExam/Base.java create mode 100644 OppsConcepts/src/com/akash/overridingMethodExam/Derived.java create mode 100644 OppsConcepts/src/com/akash/overridingMethodExam/Runner.java create mode 100644 OppsConcepts/src/com/akash/runtimepolymorphism/Audi.java create mode 100644 OppsConcepts/src/com/akash/runtimepolymorphism/Car.java create mode 100644 OppsConcepts/src/com/akash/runtimepolymorphism/Runner.java create mode 100644 OppsConcepts/src/com/akash/staticblock/MultipleStaticBlockdemo.java create mode 100644 OppsConcepts/src/com/akash/staticblock/StaticBlockVariable.java create mode 100644 OppsConcepts/src/com/akash/staticblock/StaticVariable.java create mode 100644 OppsConcepts/src/com/akash/staticblock/TestDemo.java create mode 100644 OppsConcepts/src/com/akash/stringImmutable/StringClassImmutableHashCode.java create mode 100644 OppsConcepts/src/com/akash/stringdemo/Child.java create mode 100644 OppsConcepts/src/com/akash/stringdemo/ConctTest.java create mode 100644 OppsConcepts/src/com/akash/stringdemo/ExceptionTest.java create mode 100644 OppsConcepts/src/com/akash/stringdemo/MainClassPC.java create mode 100644 OppsConcepts/src/com/akash/stringdemo/Parent.java create mode 100644 Program/src/com/akash/convertdata/Abc.java create mode 100644 Program/src/com/akash/convertdata/ConvertData.java create mode 100644 Program/src/com/akash/program/AnagramProgram.java create mode 100644 Program/src/com/akash/program/BinarySearch.java create mode 100644 Program/src/com/akash/program/CheckDigitOnly.java create mode 100644 Program/src/com/akash/program/ClassTest1.java create mode 100644 Program/src/com/akash/program/CountOddSum.java create mode 100644 Program/src/com/akash/program/FindDubplicationCharFromString.java create mode 100644 Program/src/com/akash/program/FirstSecondLargestNumInAnArray.java create mode 100644 Program/src/com/akash/program/NoDuplicationProgram.java create mode 100644 Program/src/com/akash/program/PalidromeDemo.java create mode 100644 Program/src/com/akash/program/ReverseArray.java create mode 100644 Program/src/com/akash/program/Runner.java create mode 100644 Program/src/com/akash/programming/ArmstrongNumber.java create mode 100644 Program/src/com/akash/programming/CloneExample.java create mode 100644 Program/src/com/akash/programming/ContainsOnlyLetters.java create mode 100644 Program/src/com/akash/programming/CountFrequency.java create mode 100644 Program/src/com/akash/programming/Factorial.java create mode 100644 Program/src/com/akash/programming/FibonanciSeries.java create mode 100644 Program/src/com/akash/programming/FinalCountWord.java create mode 100644 Program/src/com/akash/programming/FindLargeNumber.java create mode 100644 Program/src/com/akash/programming/FindSecondLargest.java create mode 100644 Program/src/com/akash/programming/FindUniqueElement.java create mode 100644 Program/src/com/akash/programming/FirstAndLastGet.java create mode 100644 Program/src/com/akash/programming/IteratingDemo.java create mode 100644 Program/src/com/akash/programming/MaxDifference.java create mode 100644 Program/src/com/akash/programming/PalidromeNumber.java create mode 100644 Program/src/com/akash/programming/PrimeNumber.java create mode 100644 Program/src/com/akash/programming/PushZeroToEnd.java create mode 100644 Program/src/com/akash/programming/RemoveWhiteSpace.java create mode 100644 Program/src/com/akash/programming/ReplaceMethod.java create mode 100644 Program/src/com/akash/uniquelement/FindUniqueElement.java create mode 100644 designPattern/.classpath create mode 100644 designPattern/.project create mode 100644 designPattern/.settings/org.eclipse.jdt.core.prefs create mode 100644 designPattern/Singleton.java create mode 100644 designPattern/SingletonDemo.java create mode 100644 designPattern/src/com/akash/designPattern/Singleton.java create mode 100644 designPattern/src/com/akash/designPattern/SingletonDemo.java rename {Java8Program => designPattern}/src/com/akash/factorypattern/Android.java (100%) rename {Java8Program => designPattern}/src/com/akash/factorypattern/IOS.java (100%) rename {Java8Program => designPattern}/src/com/akash/factorypattern/OS.java (100%) rename {Java8Program => designPattern}/src/com/akash/factorypattern/OperatingSystemFactory.java (100%) rename {Java8Program => designPattern}/src/com/akash/factorypattern/RunnerFactoryDesign.java (100%) rename {Java8Program => designPattern}/src/com/akash/factorypattern/Window.java (100%) create mode 100644 designPattern/src/com/akash/singleton/RunnerClass.java create mode 100644 designPattern/src/com/akash/singleton/SingletonApp.java diff --git a/ImportantCollectionApp/.classpath b/CollectionProgram/.classpath similarity index 100% rename from ImportantCollectionApp/.classpath rename to CollectionProgram/.classpath diff --git a/ImportantCollectionApp/.project b/CollectionProgram/.project similarity index 100% rename from ImportantCollectionApp/.project rename to CollectionProgram/.project diff --git a/ImportantCollectionApp/.settings/org.eclipse.jdt.core.prefs b/CollectionProgram/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from ImportantCollectionApp/.settings/org.eclipse.jdt.core.prefs rename to CollectionProgram/.settings/org.eclipse.jdt.core.prefs diff --git a/ImportantCollectionApp/src/com/akash/arrayList/AddMultipleList.java b/CollectionProgram/src/com/akash/arrayList/AddMultipleList.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/AddMultipleList.java rename to CollectionProgram/src/com/akash/arrayList/AddMultipleList.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/ArrayListContains.java b/CollectionProgram/src/com/akash/arrayList/ArrayListContains.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/ArrayListContains.java rename to CollectionProgram/src/com/akash/arrayList/ArrayListContains.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/ArrayListDemo.java b/CollectionProgram/src/com/akash/arrayList/ArrayListDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/ArrayListDemo.java rename to CollectionProgram/src/com/akash/arrayList/ArrayListDemo.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/ArrayListExample.java b/CollectionProgram/src/com/akash/arrayList/ArrayListExample.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/ArrayListExample.java rename to CollectionProgram/src/com/akash/arrayList/ArrayListExample.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/ArraySubList.java b/CollectionProgram/src/com/akash/arrayList/ArraySubList.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/ArraySubList.java rename to CollectionProgram/src/com/akash/arrayList/ArraySubList.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/CheckEmptyList.java b/CollectionProgram/src/com/akash/arrayList/CheckEmptyList.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/CheckEmptyList.java rename to CollectionProgram/src/com/akash/arrayList/CheckEmptyList.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/ConvertArrayToVector.java b/CollectionProgram/src/com/akash/arrayList/ConvertArrayToVector.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/ConvertArrayToVector.java rename to CollectionProgram/src/com/akash/arrayList/ConvertArrayToVector.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/RemoveDuplicates.java b/CollectionProgram/src/com/akash/arrayList/RemoveDuplicates.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/RemoveDuplicates.java rename to CollectionProgram/src/com/akash/arrayList/RemoveDuplicates.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/RetainAllCollection.java b/CollectionProgram/src/com/akash/arrayList/RetainAllCollection.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/RetainAllCollection.java rename to CollectionProgram/src/com/akash/arrayList/RetainAllCollection.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/SwapArrayListExample.java b/CollectionProgram/src/com/akash/arrayList/SwapArrayListExample.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/SwapArrayListExample.java rename to CollectionProgram/src/com/akash/arrayList/SwapArrayListExample.java diff --git a/ImportantCollectionApp/src/com/akash/arrayList/ToArrayDemo.java b/CollectionProgram/src/com/akash/arrayList/ToArrayDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayList/ToArrayDemo.java rename to CollectionProgram/src/com/akash/arrayList/ToArrayDemo.java diff --git a/ImportantCollectionApp/src/com/akash/arrayListException/ArrayExample.java b/CollectionProgram/src/com/akash/arrayListException/ArrayExample.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayListException/ArrayExample.java rename to CollectionProgram/src/com/akash/arrayListException/ArrayExample.java diff --git a/ImportantCollectionApp/src/com/akash/arrayListException/ArrayListConcurrentModification.java b/CollectionProgram/src/com/akash/arrayListException/ArrayListConcurrentModification.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/arrayListException/ArrayListConcurrentModification.java rename to CollectionProgram/src/com/akash/arrayListException/ArrayListConcurrentModification.java diff --git a/CollectionProgram/src/com/akash/collectionExample/ConcurrentSkipListDemo.java b/CollectionProgram/src/com/akash/collectionExample/ConcurrentSkipListDemo.java new file mode 100644 index 0000000..6f0a1bf --- /dev/null +++ b/CollectionProgram/src/com/akash/collectionExample/ConcurrentSkipListDemo.java @@ -0,0 +1,26 @@ +package com.akash.collectionExample; + +import java.util.concurrent.ConcurrentSkipListMap; + +public class ConcurrentSkipListDemo { + + public static void main(String[] args) { + ConcurrentSkipListMap map = new ConcurrentSkipListMap<>(); + ConcurrentSkipListMap skipListmap = new ConcurrentSkipListMap<>(); + + map.put("Akash", 123); + map.put("Prakash", 253); + map.put("Ravi", 103); + map.put("Rahul", 143); + + skipListmap.put(23, "Akki"); + skipListmap.put(18, "deepak"); + skipListmap.put(03, "Ravi"); + skipListmap.put(26, "rahul"); + skipListmap.put(33, "Akash"); + + System.out.println(map); + System.out.println(skipListmap); + } + +} diff --git a/CollectionProgram/src/com/akash/collectionExample/ExceptionDemo.java b/CollectionProgram/src/com/akash/collectionExample/ExceptionDemo.java new file mode 100644 index 0000000..e2b8b78 --- /dev/null +++ b/CollectionProgram/src/com/akash/collectionExample/ExceptionDemo.java @@ -0,0 +1,14 @@ +package com.akash.collectionExample; + +public class ExceptionDemo { + + public static void main(String[] args) { + + + System.out.println("try catch Start"); + System.exit(0); + + + } + +} diff --git a/CollectionProgram/src/com/akash/collectionExample/HashMapExample.java b/CollectionProgram/src/com/akash/collectionExample/HashMapExample.java new file mode 100644 index 0000000..03852d4 --- /dev/null +++ b/CollectionProgram/src/com/akash/collectionExample/HashMapExample.java @@ -0,0 +1,36 @@ +package com.akash.collectionExample; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class HashMapExample { + + public static void main(String[] args) { + Map hash = new HashMap<>(); + hash.put("Akash", 5); + hash.put("Akki", 7); + Collections.synchronizedList(new ArrayList()); + System.out.println("Result :: "+hash.hashCode()); + //System.out.println("hashCode :: "+hash.hashCode()); + Integer akash = hash.get("Akash"); + Integer akki = hash.get("Akki"); + System.out.println("Akash Get Value : "+akash.hashCode()); + if(akki.hashCode()== akash.hashCode()) { + System.out.println("Both are equal"); + }else { + System.out.println("Both are not equal"); + } + System.out.println("Akki Get Value : "+akki.hashCode()); + //hash.get("Akki").hashCode(); + + + //System.out.println(hash.hashCode()); + + + } + + + +} diff --git a/CollectionProgram/src/com/akash/collectionExample/LinkListDemo.java b/CollectionProgram/src/com/akash/collectionExample/LinkListDemo.java new file mode 100644 index 0000000..589a45d --- /dev/null +++ b/CollectionProgram/src/com/akash/collectionExample/LinkListDemo.java @@ -0,0 +1,21 @@ +package com.akash.collectionExample; + +import java.util.LinkedList; + +public class LinkListDemo { + + public static void main(String[] args) { + + LinkedList list = new LinkedList(); + + list.add("Akash"); + list.add("RAVI"); + list.add("Rahul"); + list.add("Aditya"); + + System.out.println(list); + System.out.println(list.getFirst()); + + } + +} \ No newline at end of file diff --git a/CollectionProgram/src/com/akash/collectionss/ComparaterTest.java b/CollectionProgram/src/com/akash/collectionss/ComparaterTest.java new file mode 100644 index 0000000..a0fed65 --- /dev/null +++ b/CollectionProgram/src/com/akash/collectionss/ComparaterTest.java @@ -0,0 +1,38 @@ +package com.akash.collectionss; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.TreeMap; +import java.util.TreeSet; + +public class ComparaterTest { + + public static void main(String[] args) { + // TODO + ArrayList arrayList = new ArrayList(); + + arrayList.add("one"); + arrayList.add("two"); + arrayList.add("three"); + arrayList.add("four"); + + System.out.println(arrayList); + + Collections.sort(arrayList, new StringSort()); + System.out.println(arrayList); + + TreeSet set = new TreeSet<>(); + set.add("ONE"); + set.add("THree"); + set.add("TWO"); + set.add("Four"); + set.add("Akash"); + set.add("WO"); + + System.out.println(set +" All"); + + + } + +} diff --git a/CollectionProgram/src/com/akash/collectionss/StringSort.java b/CollectionProgram/src/com/akash/collectionss/StringSort.java new file mode 100644 index 0000000..91678b6 --- /dev/null +++ b/CollectionProgram/src/com/akash/collectionss/StringSort.java @@ -0,0 +1,14 @@ +package com.akash.collectionss; + +import java.util.Comparator; + +public class StringSort implements Comparator { + + + @Override + public int compare(String arg1, String arg2) { + + return arg1.charAt(1)-arg2.charAt(1); + } + +} diff --git a/ImportantCollectionApp/src/com/akash/colonable/Runner.java b/CollectionProgram/src/com/akash/colonable/Runner.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/colonable/Runner.java rename to CollectionProgram/src/com/akash/colonable/Runner.java diff --git a/ImportantCollectionApp/src/com/akash/colonable/Test.java b/CollectionProgram/src/com/akash/colonable/Test.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/colonable/Test.java rename to CollectionProgram/src/com/akash/colonable/Test.java diff --git a/ImportantCollectionApp/src/com/akash/colonable/Test2.java b/CollectionProgram/src/com/akash/colonable/Test2.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/colonable/Test2.java rename to CollectionProgram/src/com/akash/colonable/Test2.java diff --git a/ImportantCollectionApp/src/com/akash/comparable/CollectionsSortComparable.java b/CollectionProgram/src/com/akash/comparable/CollectionsSortComparable.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/comparable/CollectionsSortComparable.java rename to CollectionProgram/src/com/akash/comparable/CollectionsSortComparable.java diff --git a/ImportantCollectionApp/src/com/akash/comparable/ComparableDemo.java b/CollectionProgram/src/com/akash/comparable/ComparableDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/comparable/ComparableDemo.java rename to CollectionProgram/src/com/akash/comparable/ComparableDemo.java diff --git a/ImportantCollectionApp/src/com/akash/comparable/ComparableObject.java b/CollectionProgram/src/com/akash/comparable/ComparableObject.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/comparable/ComparableObject.java rename to CollectionProgram/src/com/akash/comparable/ComparableObject.java diff --git a/ImportantCollectionApp/src/com/akash/comparable/Employee.java b/CollectionProgram/src/com/akash/comparable/Employee.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/comparable/Employee.java rename to CollectionProgram/src/com/akash/comparable/Employee.java diff --git a/ImportantCollectionApp/src/com/akash/comparator/ComparatorExample.java b/CollectionProgram/src/com/akash/comparator/ComparatorExample.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/comparator/ComparatorExample.java rename to CollectionProgram/src/com/akash/comparator/ComparatorExample.java diff --git a/ImportantCollectionApp/src/com/akash/comparator/Employee.java b/CollectionProgram/src/com/akash/comparator/Employee.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/comparator/Employee.java rename to CollectionProgram/src/com/akash/comparator/Employee.java diff --git a/ImportantCollectionApp/src/com/akash/concurrencyhashMap/ConcurrencyHashMapDemo.java b/CollectionProgram/src/com/akash/concurrencyhashMap/ConcurrencyHashMapDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/concurrencyhashMap/ConcurrencyHashMapDemo.java rename to CollectionProgram/src/com/akash/concurrencyhashMap/ConcurrencyHashMapDemo.java diff --git a/ImportantCollectionApp/src/com/akash/concurrencyhashMap/OccureneceNumber.java b/CollectionProgram/src/com/akash/concurrencyhashMap/OccureneceNumber.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/concurrencyhashMap/OccureneceNumber.java rename to CollectionProgram/src/com/akash/concurrencyhashMap/OccureneceNumber.java diff --git a/CollectionProgram/src/com/akash/copyonWriteArrayList/CopyOnWriteArrayThreadDemo.java b/CollectionProgram/src/com/akash/copyonWriteArrayList/CopyOnWriteArrayThreadDemo.java new file mode 100644 index 0000000..4100aea --- /dev/null +++ b/CollectionProgram/src/com/akash/copyonWriteArrayList/CopyOnWriteArrayThreadDemo.java @@ -0,0 +1,32 @@ +package com.akash.copyonWriteArrayList; + +import java.util.Iterator; +import java.util.concurrent.CopyOnWriteArrayList; + +public class CopyOnWriteArrayThreadDemo { + + public static void main(String[] args) { + CopyOnWriteArrayList arrayList = new CopyOnWriteArrayList<>(); + arrayList.add("Akash"); + arrayList.add("Abhinav"); + arrayList.add("Akki"); + arrayList.add("Priya"); + arrayList.add("sonam"); + + new Thread() { + public void run() { + Iterator iterator = arrayList.iterator(); + while(iterator.hasNext()) { + System.out.println(iterator.next()); + } + } + }.start(); + new Thread() { + public void run() { + + System.out.println("adding don't to the middle of the list"); + arrayList.add(1, "Don"); + } + }.start(); + } +} \ No newline at end of file diff --git a/ImportantCollectionApp/src/com/akash/hashmap/HashMapADemo.java b/CollectionProgram/src/com/akash/hashmap/HashMapADemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/hashmap/HashMapADemo.java rename to CollectionProgram/src/com/akash/hashmap/HashMapADemo.java diff --git a/ImportantCollectionApp/src/com/akash/hashmap/HashMapDemo.java b/CollectionProgram/src/com/akash/hashmap/HashMapDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/hashmap/HashMapDemo.java rename to CollectionProgram/src/com/akash/hashmap/HashMapDemo.java diff --git a/ImportantCollectionApp/src/com/akash/hashmap/HashMapExample.java b/CollectionProgram/src/com/akash/hashmap/HashMapExample.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/hashmap/HashMapExample.java rename to CollectionProgram/src/com/akash/hashmap/HashMapExample.java diff --git a/ImportantCollectionApp/src/com/akash/hashset/ConvertHashSet.java b/CollectionProgram/src/com/akash/hashset/ConvertHashSet.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/hashset/ConvertHashSet.java rename to CollectionProgram/src/com/akash/hashset/ConvertHashSet.java diff --git a/ImportantCollectionApp/src/com/akash/hashset/HashSetDemo.java b/CollectionProgram/src/com/akash/hashset/HashSetDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/hashset/HashSetDemo.java rename to CollectionProgram/src/com/akash/hashset/HashSetDemo.java diff --git a/ImportantCollectionApp/src/com/akash/hashtable/HashTable.java b/CollectionProgram/src/com/akash/hashtable/HashTable.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/hashtable/HashTable.java rename to CollectionProgram/src/com/akash/hashtable/HashTable.java diff --git a/ImportantCollectionApp/src/com/akash/linkedhashMap/LinkedHashMapDemo.java b/CollectionProgram/src/com/akash/linkedhashMap/LinkedHashMapDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/linkedhashMap/LinkedHashMapDemo.java rename to CollectionProgram/src/com/akash/linkedhashMap/LinkedHashMapDemo.java diff --git a/ImportantCollectionApp/src/com/akash/linkedhashSet/LinkedHashSetDemo.java b/CollectionProgram/src/com/akash/linkedhashSet/LinkedHashSetDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/linkedhashSet/LinkedHashSetDemo.java rename to CollectionProgram/src/com/akash/linkedhashSet/LinkedHashSetDemo.java diff --git a/ImportantCollectionApp/src/com/akash/linklist/LinkedListDemo.java b/CollectionProgram/src/com/akash/linklist/LinkedListDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/linklist/LinkedListDemo.java rename to CollectionProgram/src/com/akash/linklist/LinkedListDemo.java diff --git a/ImportantCollectionApp/src/com/akash/linklist/SortLinkedList.java b/CollectionProgram/src/com/akash/linklist/SortLinkedList.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/linklist/SortLinkedList.java rename to CollectionProgram/src/com/akash/linklist/SortLinkedList.java diff --git a/ImportantCollectionApp/src/com/akash/list/ArrayListCollection.java b/CollectionProgram/src/com/akash/list/ArrayListCollection.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/list/ArrayListCollection.java rename to CollectionProgram/src/com/akash/list/ArrayListCollection.java diff --git a/ImportantCollectionApp/src/com/akash/list/ArrayListDemo.java b/CollectionProgram/src/com/akash/list/ArrayListDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/list/ArrayListDemo.java rename to CollectionProgram/src/com/akash/list/ArrayListDemo.java diff --git a/ImportantCollectionApp/src/com/akash/mapi/CharCountOccurance.java b/CollectionProgram/src/com/akash/mapi/CharCountOccurance.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/mapi/CharCountOccurance.java rename to CollectionProgram/src/com/akash/mapi/CharCountOccurance.java diff --git a/ImportantCollectionApp/src/com/akash/mapi/IteratorUsingKeySet.java b/CollectionProgram/src/com/akash/mapi/IteratorUsingKeySet.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/mapi/IteratorUsingKeySet.java rename to CollectionProgram/src/com/akash/mapi/IteratorUsingKeySet.java diff --git a/ImportantCollectionApp/src/com/akash/mapi/ItertorMapDemo.java b/CollectionProgram/src/com/akash/mapi/ItertorMapDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/mapi/ItertorMapDemo.java rename to CollectionProgram/src/com/akash/mapi/ItertorMapDemo.java diff --git a/ImportantCollectionApp/src/com/akash/mapi/ItratingMapEntry.java b/CollectionProgram/src/com/akash/mapi/ItratingMapEntry.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/mapi/ItratingMapEntry.java rename to CollectionProgram/src/com/akash/mapi/ItratingMapEntry.java diff --git a/ImportantCollectionApp/src/com/akash/mapi/TreeMapDemo.java b/CollectionProgram/src/com/akash/mapi/TreeMapDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/mapi/TreeMapDemo.java rename to CollectionProgram/src/com/akash/mapi/TreeMapDemo.java diff --git a/ImportantCollectionApp/src/com/akash/set/TreeSetExample.java b/CollectionProgram/src/com/akash/set/TreeSetExample.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/set/TreeSetExample.java rename to CollectionProgram/src/com/akash/set/TreeSetExample.java diff --git a/CollectionProgram/src/com/akash/swaping/SwapingwithoutThird.java b/CollectionProgram/src/com/akash/swaping/SwapingwithoutThird.java new file mode 100644 index 0000000..f1344f4 --- /dev/null +++ b/CollectionProgram/src/com/akash/swaping/SwapingwithoutThird.java @@ -0,0 +1,25 @@ +package com.akash.swaping; + +import java.util.Scanner; + +public class SwapingwithoutThird { + + public static void main(String[] args) { + int x, y; + System.out.println("Enter the X and Y"); + Scanner scanner = new Scanner(System.in); + x = scanner.nextInt(); + y = scanner.nextInt(); + + System.out.println("Befor swaping : "+ x+""+y); + + x = x+y; + y = x-y; + x = x-y; + + System.out.println("After swapping : "+ x +""+y); + + scanner.close(); + } + +} diff --git a/CollectionProgram/src/com/akash/swaping/SwappingString.java b/CollectionProgram/src/com/akash/swaping/SwappingString.java new file mode 100644 index 0000000..ddfaa7c --- /dev/null +++ b/CollectionProgram/src/com/akash/swaping/SwappingString.java @@ -0,0 +1,21 @@ +package com.akash.swaping; + +public class SwappingString { + + public static void main(String[] args) { + // TODO + String str = "AkashKumar"; + + System.out.println(swap(str, 6, str.length()-2)); + System.out.println(swap(str, 0, str.length()-1)); + } + static char[] swap(String str, int i, int j) { + char ch[] = str.toCharArray(); + + char temp = ch[i]; + ch[i] = ch[j]; + ch[j] = temp; + + return ch; + } +} diff --git a/ImportantCollectionApp/src/com/akash/treeMap/TreeMapDemo.java b/CollectionProgram/src/com/akash/treeMap/TreeMapDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/treeMap/TreeMapDemo.java rename to CollectionProgram/src/com/akash/treeMap/TreeMapDemo.java diff --git a/ImportantCollectionApp/src/com/akash/treeMap/TreeMapReverse.java b/CollectionProgram/src/com/akash/treeMap/TreeMapReverse.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/treeMap/TreeMapReverse.java rename to CollectionProgram/src/com/akash/treeMap/TreeMapReverse.java diff --git a/ImportantCollectionApp/src/com/akash/treeSet/TreeSetDemo.java b/CollectionProgram/src/com/akash/treeSet/TreeSetDemo.java similarity index 100% rename from ImportantCollectionApp/src/com/akash/treeSet/TreeSetDemo.java rename to CollectionProgram/src/com/akash/treeSet/TreeSetDemo.java diff --git a/DataStructure/.classpath b/DataStructure/.classpath new file mode 100644 index 0000000..e461bea --- /dev/null +++ b/DataStructure/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/DataStructure/.project b/DataStructure/.project new file mode 100644 index 0000000..1d66c10 --- /dev/null +++ b/DataStructure/.project @@ -0,0 +1,17 @@ + + + DataStructure + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/DataStructure/.settings/org.eclipse.jdt.core.prefs b/DataStructure/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/DataStructure/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/DataStructure/src/com/akash/binarySearch/BinaryRecursion.java b/DataStructure/src/com/akash/binarySearch/BinaryRecursion.java new file mode 100644 index 0000000..edad2c6 --- /dev/null +++ b/DataStructure/src/com/akash/binarySearch/BinaryRecursion.java @@ -0,0 +1,25 @@ +package com.akash.binarySearch; + +import java.util.Scanner; + +public class BinaryRecursion { + + public static void main(String[] args) { + int first, middle, last, search; + System.out.println("Enter the number of Elements"); + Scanner scanner = new Scanner(System.in); + int number = scanner.nextInt(); + int array[] = new int[number]; + System.out.println("Enter "+number +" Integers"); + for(int i = 0; i0) { + temp = str[i]; + str[i] = str[j]; + str[j] = temp; + } + } + } + } +} \ No newline at end of file diff --git a/DataStructure/src/com/akash/dataStructure/InsertArray.java b/DataStructure/src/com/akash/dataStructure/InsertArray.java new file mode 100644 index 0000000..fd3b461 --- /dev/null +++ b/DataStructure/src/com/akash/dataStructure/InsertArray.java @@ -0,0 +1,30 @@ +package com.akash.dataStructure; + +public class InsertArray { + + public static void main(String[] args) { + + int arr[] = {1, 8, 6, 2, 4, 7, 3, 4}; + + int length = arr.length; + + insertArray(arr, length); + + for(int i = 0; i arr[j]) { + + temp = arr[i]; + arr[i] = arr[j]; + + arr[j] = temp; + } + } + } + + } + + +} diff --git a/DataStructure/src/com/akash/dataStructure/SplitArray.java b/DataStructure/src/com/akash/dataStructure/SplitArray.java new file mode 100644 index 0000000..636b664 --- /dev/null +++ b/DataStructure/src/com/akash/dataStructure/SplitArray.java @@ -0,0 +1,44 @@ +package com.akash.dataStructure; + +public class SplitArray { + + public static void main(String[] args) { + + System.out.println(" All the Array "); + + int arr[] = {1,55, 6, 7 ,9 ,4, 2, 7}; + int length = arr.length; + int target = 4; + splitArray(target, length, arr); + } + + private static void splitArray(int target, int length, int[] arr) { + int count = 0; + int counts = 0; + int a[] = new int[8]; + int b[] = new int[8]; + + for(int i = 0; i0 && arr[j-1]>temp) { + arr[j] = arr[j-1]; + j = j-1; + } + arr[j] = temp; + } + } +} \ No newline at end of file diff --git a/DataStructure/src/com/akash/mergeList/MergeSort.java b/DataStructure/src/com/akash/mergeList/MergeSort.java new file mode 100644 index 0000000..5dc0cac --- /dev/null +++ b/DataStructure/src/com/akash/mergeList/MergeSort.java @@ -0,0 +1,81 @@ +package com.akash.mergeList; + +public class MergeSort { + + int[] array; + int[] tempMergeArr; + int length; + + /*it is basically work divide and conquer + * Recursive method + * */ + public static void main(String[] args) { + // TODO + + int arr[] = {15, 12, 96, 2, 46, 71, 63, 13, 6}; + + MergeSort mergeSort = new MergeSort(); + mergeSort.sort(arr); + + for(int i : arr) { + System.out.print(i+" "); + } + } + + private void sort(int[] arr) { + // TODO + this.array = arr; + this.length = arr.length; + this.tempMergeArr = new int[length]; + divideArray(0, length-1); + } + + private void divideArray(int lowerIndex, int higherIndex) { + // TODO + + if(lowerIndex < higherIndex) { + + int middle = lowerIndex +(higherIndex-lowerIndex)/2; + + /*it will sort the left side of an array*/ + divideArray(lowerIndex, middle); + + /*it will sort the right side of an array*/ + divideArray(middle+1, higherIndex); + + mergeArray(lowerIndex, middle, higherIndex); + } + } + + private void mergeArray(int lowerIndex, int middle, int higherIndex) { + // TODO + + for(int i = lowerIndex; i<=higherIndex; i++) { + tempMergeArr[i] = array[i]; + } + + int i = lowerIndex; + int j = middle+1; + int k = lowerIndex; + + while(i<=middle && j<=higherIndex) { + + if(tempMergeArr[i] <= tempMergeArr[j]) { + + array[k] = tempMergeArr[i]; + i++; + }else { + array[k] = tempMergeArr[j]; + j++; + } + k++; + } + while(i<=middle) { + array[k] = tempMergeArr[i]; + k++; + i++; + } + + } + // To do +} \ No newline at end of file diff --git a/DataStructure/src/com/akash/middleList/FindMiddleLinkedList.java b/DataStructure/src/com/akash/middleList/FindMiddleLinkedList.java new file mode 100644 index 0000000..04a32eb --- /dev/null +++ b/DataStructure/src/com/akash/middleList/FindMiddleLinkedList.java @@ -0,0 +1,46 @@ +package com.akash.middleList; + +public class FindMiddleLinkedList { + Node head; + + class Node{ + int data; + Node next; + Node(int d){ + data = d; + next = null; + } + } + void printMiddle() { + Node slow_ptr = head; + Node fast_ptr = head; + if(head != null) { + while(fast_ptr != null && fast_ptr.next != null) { + fast_ptr = fast_ptr.next.next; + slow_ptr = slow_ptr.next; + } + System.out.println("The middle element is "+ slow_ptr.data + " \n"); + } + } + public void pushNode(int newData ) { + Node newNode = new Node(newData); + newNode.next = head; + head = newNode; + } + public void printList() { + Node pnode = head; + while(pnode != null) { + System.out.println(pnode.data+ " -> "); + pnode = pnode.next; + } + System.out.println("NULL"); + } + public static void main(String[] args) { + FindMiddleLinkedList find = new FindMiddleLinkedList(); + for(int i = 5; i>0; --i) { + find.pushNode(i); + find.printList(); + find.printMiddle(); + } + } +} \ No newline at end of file diff --git a/DataStructure/src/com/akash/reverseLinked/ReverseLinked.java b/DataStructure/src/com/akash/reverseLinked/ReverseLinked.java new file mode 100644 index 0000000..277d6dd --- /dev/null +++ b/DataStructure/src/com/akash/reverseLinked/ReverseLinked.java @@ -0,0 +1,57 @@ +package com.akash.reverseLinked; + +public class ReverseLinked { + + static Node head; + + static class Node { + int data; + Node next; + + public Node(int d){ + data = d; + next = null; + } + } + + /* print content of double linked list */ + + void printList(Node node) { + while(node != null) { + System.out.println(node.data+ " "); + node = node.next; + } + } + + /* function to reverse linked list*/ + Node reverse(Node node) { + Node prev = null; + Node current = node; + Node next = null; + + while(current!= null ) { + next = current.next; + current.next = prev; + prev = current; + current = next; + } + node = prev; + return node; + } + + public static void main(String[] args) { + ReverseLinked linked = new ReverseLinked(); + linked.head = new Node(85); + linked.head.next = new Node(50); + linked.head.next.next = new Node(70); + linked.head.next.next.next = new Node(60); + + System.out.println("Given linked list"); + linked.printList(head); + head = linked.reverse(head); + System.out.println(" "); + System.out.println("Reverse Linked List"); + linked.printList(head); + + } +} \ No newline at end of file diff --git a/DataStructure/src/com/akash/reverseLinked/ReverseLinkedList.java b/DataStructure/src/com/akash/reverseLinked/ReverseLinkedList.java new file mode 100644 index 0000000..92d80d5 --- /dev/null +++ b/DataStructure/src/com/akash/reverseLinked/ReverseLinkedList.java @@ -0,0 +1,57 @@ +package com.akash.reverseLinked; + +public class ReverseLinkedList { + + static Node head; + + static class Node{ + int data; + Node next; + + Node(int d){ + data = d; + next = null; + } + } + + public Node reverse(Node node) { + Node current = node; + Node next = null; + Node prev = null; + + while(current != null) { + next = current.next; + current.next = prev; + prev = current; + current = next; + } + node = prev; + + return node; + } + + void printList(Node node) { + while (node != null) { + System.out.print(node.data + " "); + node = node.next; + } + } + + + public static void main(String[] args) { + // TODO + ReverseLinkedList list = new ReverseLinkedList(); + list.head = new Node(20); + list.head.next = new Node(30); + list.head.next.next = new Node(40); + list.head.next.next.next = new Node(50); + + System.out.println(" Original "); + list.printList(head);; + head = list.reverse(head); + System.out.println(" "); + System.out.println(" Reverse linked list "); + list.printList(head); + + } +} \ No newline at end of file diff --git a/Exception/.classpath b/Exception/.classpath new file mode 100644 index 0000000..e461bea --- /dev/null +++ b/Exception/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Exception/.project b/Exception/.project new file mode 100644 index 0000000..1eb9b16 --- /dev/null +++ b/Exception/.project @@ -0,0 +1,17 @@ + + + Exception + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Exception/.settings/org.eclipse.jdt.core.prefs b/Exception/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/Exception/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Exception/src/com/akash/ExceptionThrow/ThrowExcept.java b/Exception/src/com/akash/ExceptionThrow/ThrowExcept.java new file mode 100644 index 0000000..a804dd1 --- /dev/null +++ b/Exception/src/com/akash/ExceptionThrow/ThrowExcept.java @@ -0,0 +1,25 @@ +package com.akash.ExceptionThrow; + +public class ThrowExcept extends Exception{ + + /** + * + */ + private static final long serialVersionUID = 1L; + public static void main(String[] args) throws ThrowExcept { + ExceptionHandle.valid(20); + System.out.println("Testing....."); + } + public ThrowExcept(String s) { + // TODO + super(s); + } + +} +class ExceptionHandle{ + static void valid(int i) throws ThrowExcept { + if(i<18) { + throw new ThrowExcept("No Valid"); + } + } +} \ No newline at end of file diff --git a/Exception/src/com/akash/ExceptionThrow/ThrowsException.java b/Exception/src/com/akash/ExceptionThrow/ThrowsException.java new file mode 100644 index 0000000..c47de29 --- /dev/null +++ b/Exception/src/com/akash/ExceptionThrow/ThrowsException.java @@ -0,0 +1,25 @@ +package com.akash.ExceptionThrow; + +public class ThrowsException extends RuntimeException{ + + /** + * + */ + private static final long serialVersionUID = 1L; + public static void main(String[] args) { + ThrowsExce.valid(20); + System.out.println("Testing....."); + } + public ThrowsException(String s) { + // TODO + super(s); + } + +} +class ThrowsExce{ + static void valid(int i) { + if(i<18) { + throw new ThrowsException("No Valid"); + } + } +} \ No newline at end of file diff --git a/Exception/src/com/akash/arithmatic/ArithmaticExceptionDemo.java b/Exception/src/com/akash/arithmatic/ArithmaticExceptionDemo.java new file mode 100644 index 0000000..2d01074 --- /dev/null +++ b/Exception/src/com/akash/arithmatic/ArithmaticExceptionDemo.java @@ -0,0 +1,22 @@ +package com.akash.arithmatic; + +public class ArithmaticExceptionDemo { + + public static void main(String[] args) { + // TODO + try { + System.out.println("My channel is favorite...."); // execute + + int c = 10/0; // exception + System.out.println("Result : "+ c); + + }finally { + System.out.println("I am finally block"); // execute + } + + System.out.println("Hey Everyone"); + System.out.println("Pls help me !!!!!!!!!"); + + } + +} diff --git a/Exception/src/com/akash/calculatorException/Calculator.java b/Exception/src/com/akash/calculatorException/Calculator.java new file mode 100644 index 0000000..ddc8ff0 --- /dev/null +++ b/Exception/src/com/akash/calculatorException/Calculator.java @@ -0,0 +1,15 @@ +package com.akash.calculatorException; + +public class Calculator { + + public void divide(int fn, int sn) { + System.out.println("Division Start....."); + try { + int res = fn/sn; + System.out.println(" Result : "+res); + }catch(ArithmeticException e) { + System.out.println("hey Golu ...... Enter proper value"+ e); + } + System.out.println("Division end...."); + } +} diff --git a/Exception/src/com/akash/calculatorException/Runner.java b/Exception/src/com/akash/calculatorException/Runner.java new file mode 100644 index 0000000..50153aa --- /dev/null +++ b/Exception/src/com/akash/calculatorException/Runner.java @@ -0,0 +1,20 @@ +package com.akash.calculatorException; + +import java.util.Scanner; + +public class Runner { + + public static void main(String[] args) { + // TODO + System.out.println("...App Start..."); + Scanner scanner = new Scanner(System.in); + System.out.println("Enter the Number"); + int fn = scanner.nextInt(); + int sn = scanner.nextInt(); + + scanner.close(); + Calculator calculator = new Calculator(); + calculator.divide(fn, sn); + System.out.println("App Close"); + } +} \ No newline at end of file diff --git a/Exception/src/com/akash/exceptionBlock/ExceptionChainingDmo.java b/Exception/src/com/akash/exceptionBlock/ExceptionChainingDmo.java new file mode 100644 index 0000000..088030e --- /dev/null +++ b/Exception/src/com/akash/exceptionBlock/ExceptionChainingDmo.java @@ -0,0 +1,22 @@ +package com.akash.exceptionBlock; + +public class ExceptionChainingDmo { + + public static void main(String[] args) { + // TODO + getBlock(); + } + + public static void getBlock() { + // TODO + /*occurs when an exception is thrown in response to another exception. This allows + * us to discover the complete history of our raised problem*/ + try { + System.out.println(2); + }catch(ArithmeticException e) { + System.out.println(e); + }finally { + System.out.println("Hello"); + } + } +} diff --git a/Exception/src/com/akash/exceptionBlock/ExceptionDemo.java b/Exception/src/com/akash/exceptionBlock/ExceptionDemo.java new file mode 100644 index 0000000..9042da6 --- /dev/null +++ b/Exception/src/com/akash/exceptionBlock/ExceptionDemo.java @@ -0,0 +1,28 @@ +package com.akash.exceptionBlock; + +public class ExceptionDemo { + + public static void main(String[] args) { + // TODO + getHello(); + } + + public static void getHello() { + // TODO + + String str = "Hello"; + try { + int i = 1/0; + System.out.println(i); + + } catch (ArithmeticException | ArrayIndexOutOfBoundsException e) { + System.out.println("catch block"); + // TODO: handle exception + }finally { + System.out.println("hey"); + } + System.out.println(str); + + } + +} diff --git a/Exception/src/com/akash/exceptionLogic/ExceptionIncrement.java b/Exception/src/com/akash/exceptionLogic/ExceptionIncrement.java new file mode 100644 index 0000000..2e90259 --- /dev/null +++ b/Exception/src/com/akash/exceptionLogic/ExceptionIncrement.java @@ -0,0 +1,25 @@ +package com.akash.exceptionLogic; + +public class ExceptionIncrement { + + public static void main(String[] args) { + // TODO + try { + int i=1; int j= 1; + i++; + j--; + if(i==j) { + System.out.println("Hello"); + } + } catch (ArithmeticException e) { + // TODO: + System.out.println("ArithmaticException : "+ e); + }catch(ArrayIndexOutOfBoundsException ea) { + System.out.println("ArrayIndexBoundException : "+ ea); + }catch(Exception ex) { + System.out.println("Exception : "+ ex); + }finally { + System.out.println("Finally block"); + } + } +} \ No newline at end of file diff --git a/Exception/src/com/akash/exceptions/ExceptionDemo.java b/Exception/src/com/akash/exceptions/ExceptionDemo.java new file mode 100644 index 0000000..d1df758 --- /dev/null +++ b/Exception/src/com/akash/exceptions/ExceptionDemo.java @@ -0,0 +1,41 @@ +package com.akash.exceptions; + +public class ExceptionDemo { + + public static void main(String[] args) { + final int s; + + // TODO + int a= 2; + System.out.println(a); + System.out.println(hello(15)); + + /*try { + if(a== 2) { + System.out.println("Yes"); + } + + } catch (Exception e) { + // TODO: handle exception + System.out.println("err"); + }finally { + b= 2; + System.out.println(b); + System.out.println("finally"); + }*/ + } + + public static int hello(int a) { + try { + System.out.println("try"); + return a; + + } catch (Exception e) { + // TODO: handle exception + System.out.println("catch"); + }finally { + System.out.println("hello"); + } + return a; + } +} \ No newline at end of file diff --git a/Exception/src/com/akash/exceptions/ExceptionExample.java b/Exception/src/com/akash/exceptions/ExceptionExample.java new file mode 100644 index 0000000..c027ab1 --- /dev/null +++ b/Exception/src/com/akash/exceptions/ExceptionExample.java @@ -0,0 +1,24 @@ +package com.akash.exceptions; + +public class ExceptionExample { + + public static void main(String[] args) { + // TODO + getInstances(); + } + public static void getInstances() { + // TODO + final int a= 5; + System.out.println(a); + try { + int s= 562; + System.out.println(s + " try block"); + } finally { + // TODO: handle finally clause + String s = "Akash"; + System.out.println("finally "+ s); + } + int b = 65; + System.out.println(b); + } +} \ No newline at end of file diff --git a/Exception/src/com/akash/exceptions/TryCatchException.java b/Exception/src/com/akash/exceptions/TryCatchException.java new file mode 100644 index 0000000..5050244 --- /dev/null +++ b/Exception/src/com/akash/exceptions/TryCatchException.java @@ -0,0 +1,23 @@ +package com.akash.exceptions; + +public class TryCatchException { + + public static void main(String[] args) { + // TODO + getExampleDemo(); + } + + public static void getExampleDemo() { + // TODO + + try{ + int i = 1/0; + System.out.println("my resource is failure....."+ i); + } catch (Exception e) { + System.out.println("execute catch : "+ e); + // TODO: handle exception + }finally { + System.out.println("it is always execute. it is important code such as closing"); + } + } +} \ No newline at end of file diff --git a/Exception/src/com/akash/finalException/FinalVariableExample.java b/Exception/src/com/akash/finalException/FinalVariableExample.java new file mode 100644 index 0000000..958a09f --- /dev/null +++ b/Exception/src/com/akash/finalException/FinalVariableExample.java @@ -0,0 +1,12 @@ +package com.akash.finalException; + +public class FinalVariableExample { + + public static void main(String[] args) { + + final int a=1; // declared final method + //a = 15; // so cannot change bcz its restriction class, method and variable + System.out.println(a); + } + +} diff --git a/Exception/src/com/akash/finallizeExample/FinalizeExample.java b/Exception/src/com/akash/finallizeExample/FinalizeExample.java new file mode 100644 index 0000000..fb0cd08 --- /dev/null +++ b/Exception/src/com/akash/finallizeExample/FinalizeExample.java @@ -0,0 +1,26 @@ +package com.akash.finallizeExample; + +public class FinalizeExample { + + public void finalize() { + System.out.println("Finalize is called ...."); + } + + public static void main(String[] args) { + + // finalize is used to perform clean up processing just + // before object is garbage collected. + + FinalizeExample finalizeExample = new FinalizeExample(); + FinalizeExample finalizeExample2 = new FinalizeExample(); + + System.out.println(finalizeExample); + System.out.println(finalizeExample2); + + finalizeExample = null; + finalizeExample2 = null; + System.gc(); + + } + +} diff --git a/Exception/src/com/akash/finallyException/FinallyExampleException.java b/Exception/src/com/akash/finallyException/FinallyExampleException.java new file mode 100644 index 0000000..ff3d018 --- /dev/null +++ b/Exception/src/com/akash/finallyException/FinallyExampleException.java @@ -0,0 +1,21 @@ +package com.akash.finallyException; + +public class FinallyExampleException { + + public static void main(String[] args) { + + try { + int x = 100; + System.out.println(x); + } + catch(Exception e ) { + System.out.println(e); + } + + // it will be executed whether execution is handled or not + + finally { + System.out.println("Finally block is executing........."); + } + } +} diff --git a/Exception/src/com/akash/throwsDemo/ExceptionDemo.java b/Exception/src/com/akash/throwsDemo/ExceptionDemo.java new file mode 100644 index 0000000..a5fb02a --- /dev/null +++ b/Exception/src/com/akash/throwsDemo/ExceptionDemo.java @@ -0,0 +1,32 @@ +package com.akash.throwsDemo; + +import java.util.HashSet; +import java.util.Set; + +public class ExceptionDemo { + + + public static void main(String[] args) { + /*try { + //throw ; + + } catch (Exception e) { + // TODO: + }finally { + + }*/ + + Set set = new HashSet<>(); + + set.add("1"); + set.add("6"); + set.add("3"); + set.add(null); + set.add("0"); + + System.out.println(set); + System.out.println(set.getClass()); + + } + +} diff --git a/ImportantLogical/.classpath b/ImportantLogical/.classpath new file mode 100644 index 0000000..e461bea --- /dev/null +++ b/ImportantLogical/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/ImportantLogical/.project b/ImportantLogical/.project new file mode 100644 index 0000000..a8a7889 --- /dev/null +++ b/ImportantLogical/.project @@ -0,0 +1,17 @@ + + + ImportantLogical + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/ImportantLogical/.settings/org.eclipse.jdt.core.prefs b/ImportantLogical/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/ImportantLogical/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/ImportantLogical/src/com/akash/abstractfinal/Bank.java b/ImportantLogical/src/com/akash/abstractfinal/Bank.java new file mode 100644 index 0000000..b28841e --- /dev/null +++ b/ImportantLogical/src/com/akash/abstractfinal/Bank.java @@ -0,0 +1,8 @@ +package com.akash.abstractfinal; + +public interface Bank{ + + void credit(); + void save(); + +} diff --git a/ImportantLogical/src/com/akash/abstractfinal/Sbi.java b/ImportantLogical/src/com/akash/abstractfinal/Sbi.java new file mode 100644 index 0000000..c1bca11 --- /dev/null +++ b/ImportantLogical/src/com/akash/abstractfinal/Sbi.java @@ -0,0 +1,8 @@ +package com.akash.abstractfinal; + +public abstract class Sbi implements Bank { + + + + +} \ No newline at end of file diff --git a/ImportantLogical/src/com/akash/instanceInitail/ConstructorInitial.java b/ImportantLogical/src/com/akash/instanceInitail/ConstructorInitial.java new file mode 100644 index 0000000..f49e656 --- /dev/null +++ b/ImportantLogical/src/com/akash/instanceInitail/ConstructorInitial.java @@ -0,0 +1,38 @@ +package com.akash.instanceInitail; + +public class ConstructorInitial { + + //Every call object then call instance block + // but static block call only once when call every time object + // initial block start.... + static{ + int i=0; + System.out.println("Static block"+i); + } + + { + System.out.println("initial instance block...."); + } + + public ConstructorInitial(int j) { + System.out.println("hey i am int parameterized constructor"+ j); + } + public ConstructorInitial(){ + System.out.println("default constructor"); + } + public ConstructorInitial(String name){ + System.out.println("parametrized constructor " + name); + } + public static void main(String[] args) { + // TODO + + ConstructorInitial constructorInitial = new ConstructorInitial(); + System.out.println(constructorInitial); + ConstructorInitial constructorInitial2 = new ConstructorInitial(156); + System.out.println(constructorInitial2); + ConstructorInitial constructorInitial3 = new ConstructorInitial("String"); + System.out.println(constructorInitial3); + + } + +} diff --git a/ImportantLogical/src/com/akash/instanceInitail/InstanceBlock.java b/ImportantLogical/src/com/akash/instanceInitail/InstanceBlock.java new file mode 100644 index 0000000..ecc0b17 --- /dev/null +++ b/ImportantLogical/src/com/akash/instanceInitail/InstanceBlock.java @@ -0,0 +1,31 @@ +package com.akash.instanceInitail; + +public class InstanceBlock { + + { + // 2nd execute + System.out.println("instance Block....."); // 2nd + } + + static { + // 1st execute + System.out.println("hello i am static block"); // 1st + } + + public InstanceBlock() { + // 4rd execute + // TODO + System.out.println("hello i am constructor ..."); // 4rd + } + + { + // 3rd execute + System.out.println("hello I instance 2"); // 3rd + } + public static void main(String[] args) { + // TODO + InstanceBlock instanceBlock = new InstanceBlock(); + System.out.println("instance Object "+ instanceBlock); + } + +} diff --git a/ImportantLogical/src/com/akash/instanceInitail/StaticBlock.java b/ImportantLogical/src/com/akash/instanceInitail/StaticBlock.java new file mode 100644 index 0000000..440f08d --- /dev/null +++ b/ImportantLogical/src/com/akash/instanceInitail/StaticBlock.java @@ -0,0 +1,26 @@ +package com.akash.instanceInitail; + +public class StaticBlock { + + public static void main(String[] args) { + System.out.println("how to main method"); + new StaticBlock(); + System.out.println(new StaticBlock().j); + System.out.println(i); + } + static int i; + int j=20; + { + System.out.println("I am Instance"); + } + static{ + i =10; + System.out.println("static block is : "+ i); + } + + public StaticBlock() { + System.out.println("I am constructor"); + } + + +} diff --git a/ImportantLogical/src/com/akash/staticblock/MultipleStaticBlockdemo.java b/ImportantLogical/src/com/akash/staticblock/MultipleStaticBlockdemo.java new file mode 100644 index 0000000..79e39b5 --- /dev/null +++ b/ImportantLogical/src/com/akash/staticblock/MultipleStaticBlockdemo.java @@ -0,0 +1,26 @@ +package com.akash.staticblock; + +public class MultipleStaticBlockdemo { + + static int num; + static String str; + + static { + System.out.println("static block 1"); // 1st execute + num = 68; + str= "Block1"; + } + static { + System.out.println("Static block 2"); // 2nd execute + num = 70; + str = "Block2"; + } + public static void main(String[] args) { + // TODO + System.out.println("value of num: "+ num); // 3rd execute in second block2 + System.out.println("value of str: "+ str); // 4th block in second block2 + + + } + +} diff --git a/ImportantLogical/src/com/akash/staticblock/StaticBlockVariable.java b/ImportantLogical/src/com/akash/staticblock/StaticBlockVariable.java new file mode 100644 index 0000000..ff6d856 --- /dev/null +++ b/ImportantLogical/src/com/akash/staticblock/StaticBlockVariable.java @@ -0,0 +1,33 @@ +package com.akash.staticblock; + +public class StaticBlockVariable { + + static int var1= 54; + String var2; + + public static void main(String[] args) { + // TODO + StaticBlockVariable staticBlockVariable = new StaticBlockVariable(); + StaticBlockVariable staticBlockVariable2 = new StaticBlockVariable(); + + staticBlockVariable.var1=10; // 20 + staticBlockVariable.var2="Hello 1st"; // same + + + staticBlockVariable2.var1= 30; // 20 + staticBlockVariable2.var2="Hello 2nd"; // same + + var1=62; + + /*This will overwrite the value of var1 because var1 has a single + * copy shared among both the objects */ + + System.out.println("obj 1 int : "+ staticBlockVariable.var1); + System.out.println("obj 1 string : "+ staticBlockVariable.var2); + System.out.println("obj 2 int : "+ staticBlockVariable2.var1); + System.out.println("obj 2 String : "+ staticBlockVariable2.var2); + System.out.println("obj 2 Intance : "+ var1); + + } + +} \ No newline at end of file diff --git a/ImportantLogical/src/com/akash/staticblock/StaticVariable.java b/ImportantLogical/src/com/akash/staticblock/StaticVariable.java new file mode 100644 index 0000000..4eff92b --- /dev/null +++ b/ImportantLogical/src/com/akash/staticblock/StaticVariable.java @@ -0,0 +1,22 @@ +package com.akash.staticblock; + +public class StaticVariable { + + int var1; + static int var3; + static String var2; + public static void main(String[] args) { + // TODO + disp(); + + } + + public static void disp() { + // TODO + System.out.println("var1 is "+ new StaticVariable().var1); // 0 + System.out.println("var1 is "+ var2); // null + System.out.println("var1 is "+ var3); // 0 + + } + +} diff --git a/ImportantLogical/src/com/akash/staticblock/TestDemo.java b/ImportantLogical/src/com/akash/staticblock/TestDemo.java new file mode 100644 index 0000000..6195778 --- /dev/null +++ b/ImportantLogical/src/com/akash/staticblock/TestDemo.java @@ -0,0 +1,6 @@ +package com.akash.staticblock; + +public interface TestDemo { + static int i=6; + +} diff --git a/ImportantLogical/src/com/akash/tryCatch/FinallyBlock.java b/ImportantLogical/src/com/akash/tryCatch/FinallyBlock.java new file mode 100644 index 0000000..2b5c727 --- /dev/null +++ b/ImportantLogical/src/com/akash/tryCatch/FinallyBlock.java @@ -0,0 +1,23 @@ +package com.akash.tryCatch; + +public class FinallyBlock { + + public static void main(String[] args) { + // TODO + System.out.println(count()); + } + + public static int count() { + try { + /* 2nd Execute */ + System.out.println("Hey"); + return 1; + } catch (Exception e) { + return 2; + // TODO: handle exception + }finally { + System.out.println(" Finally block will execute even after a return statement "); + /* 1st Execute */ + } + } +} \ No newline at end of file diff --git a/ImportantProgram/.classpath b/ImportantProgram/.classpath new file mode 100644 index 0000000..e461bea --- /dev/null +++ b/ImportantProgram/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/ImportantProgram/.project b/ImportantProgram/.project new file mode 100644 index 0000000..3749e81 --- /dev/null +++ b/ImportantProgram/.project @@ -0,0 +1,17 @@ + + + JavaItertor + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/ImportantProgram/.settings/org.eclipse.jdt.core.prefs b/ImportantProgram/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/ImportantProgram/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/ImportantProgram/src/com/akash/cloneDemo/CloneDemoExample.java b/ImportantProgram/src/com/akash/cloneDemo/CloneDemoExample.java new file mode 100644 index 0000000..470d194 --- /dev/null +++ b/ImportantProgram/src/com/akash/cloneDemo/CloneDemoExample.java @@ -0,0 +1,24 @@ +package com.akash.cloneDemo; + +public class CloneDemoExample implements Cloneable{ + + String sal; + String size; + String company; + + public static void main(String[] args) throws CloneNotSupportedException { + // TODO Auto-generated method stub + + CloneDemoExample clones = new CloneDemoExample(); + clones.sal="400000"; + clones.size="24"; + clones.company="FIS"; + + CloneDemoExample cDemo = (CloneDemoExample)clones.clone(); + + System.out.println(cDemo.sal +" another Clone Man"); + System.out.println(cDemo.size +" another Clone Man"); + System.out.println(cDemo.company +" another Clone Man"); + } + +} diff --git a/ImportantProgram/src/com/akash/enumDemo/Element.java b/ImportantProgram/src/com/akash/enumDemo/Element.java new file mode 100644 index 0000000..4fc04a6 --- /dev/null +++ b/ImportantProgram/src/com/akash/enumDemo/Element.java @@ -0,0 +1,31 @@ +package com.akash.enumDemo; + +public enum Element { + HELIUM("He", "Gas"), + MAGNESIUM("Mg", "Solid"); + + private String chemicalSymbol; + private String nature; + + private Element(String newChemicalSymbol, String newNature) { + chemicalSymbol = newChemicalSymbol; + nature = newNature; + } + + public String chemicalSymbol() { + return chemicalSymbol; + } + + public String nature() { + return nature; + } + + + public static void main(String[] args) { + System.out.println("Element.HELIUM"); + System.out.printf("%s, %s, %s", Element.HELIUM, Element.MAGNESIUM, Element.HELIUM.chemicalSymbol(), Element.MAGNESIUM.nature()); + System.out.printf("%s, %s, %s", Element.HELIUM.toString(), Element.HELIUM.chemicalSymbol(), Element.MAGNESIUM.nature()); + + } + +} diff --git a/ImportantProgram/src/com/akash/enumExample/Account.java b/ImportantProgram/src/com/akash/enumExample/Account.java new file mode 100644 index 0000000..197438b --- /dev/null +++ b/ImportantProgram/src/com/akash/enumExample/Account.java @@ -0,0 +1,11 @@ +package com.akash.enumExample; + +public class Account { + private Type accountType; + public void add(Type newType) { + accountType = newType; + } + public Type get() { + return accountType; + } +} diff --git a/ImportantProgram/src/com/akash/enumExample/Accounts.java b/ImportantProgram/src/com/akash/enumExample/Accounts.java new file mode 100644 index 0000000..fd8f741 --- /dev/null +++ b/ImportantProgram/src/com/akash/enumExample/Accounts.java @@ -0,0 +1,13 @@ +package com.akash.enumExample; + +public class Accounts { + + private S accountType; + public void add(S newType) { + accountType = newType; + } + public S get() { + return accountType; + } + +} diff --git a/ImportantProgram/src/com/akash/enums/EnumExample.java b/ImportantProgram/src/com/akash/enums/EnumExample.java new file mode 100644 index 0000000..1ec1450 --- /dev/null +++ b/ImportantProgram/src/com/akash/enums/EnumExample.java @@ -0,0 +1,11 @@ +package com.akash.enums; + +public class EnumExample { + + public static void main(String[] args) { + // TODO + System.out.println(Mobile.Apple); + + } + +} diff --git a/ImportantProgram/src/com/akash/enums/Mobile.java b/ImportantProgram/src/com/akash/enums/Mobile.java new file mode 100644 index 0000000..5d1adfc --- /dev/null +++ b/ImportantProgram/src/com/akash/enums/Mobile.java @@ -0,0 +1,8 @@ +package com.akash.enums; + +public enum Mobile { + + // it is final and static. we can access directly + Apple, HTC, Samsung, Lenovo, Motorola, Panasonic, Redmi + +} diff --git a/ImportantProgram/src/com/akash/hashCodeAndEquals/HashCodeAndEquals.java b/ImportantProgram/src/com/akash/hashCodeAndEquals/HashCodeAndEquals.java new file mode 100644 index 0000000..afac978 --- /dev/null +++ b/ImportantProgram/src/com/akash/hashCodeAndEquals/HashCodeAndEquals.java @@ -0,0 +1,65 @@ +package com.akash.hashCodeAndEquals; + +import java.util.HashMap; +import java.util.Map; + +public class HashCodeAndEquals { + + public static void main(String[] args) { + // TODO + Employee e1= new Employee(1); + Employee e2= new Employee(1); + + Map map = new HashMap(); + map.put(e1, "1"); + map.put(e2, "1"); + + Map hmap = new HashMap<>(); + hmap.put("Akash", 25); + hmap.put("Ravi", 25); + + System.out.println("HMap :: "+hmap.size()); + + System.out.println(map.size()); // guess it + System.out.println(map.entrySet()); //convert list + + // clue + Integer i1 = new Integer(1); + Integer i2 = new Integer(1); + Map map1 = new HashMap<>(); + map1.put(i1, "one"); + map1.put(i2, "one"); + + System.out.println(map1.size()); // output // 1 + } +} +class Employee{ + int id; + + public Employee(int id) { + this.id=id; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + id; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Employee other = (Employee) obj; + if (id != other.id) + return false; + return true; + } + +} diff --git a/ImportantProgram/src/com/akash/itertorDemo/ItertorDemo.java b/ImportantProgram/src/com/akash/itertorDemo/ItertorDemo.java new file mode 100644 index 0000000..de8a6a7 --- /dev/null +++ b/ImportantProgram/src/com/akash/itertorDemo/ItertorDemo.java @@ -0,0 +1,41 @@ +package com.akash.itertorDemo; + +import java.util.Iterator; +import java.util.LinkedList; + +public class ItertorDemo { + + public static void main(String[] args) { + // TODO + //hasNext() : it check value present or not + // next(): it is printing value next + + LinkedList list = new LinkedList<>(); + list.add("Akash"); + list.add("Badshah"); + list.add("Dev"); + list.add("Rahul"); + list.add("Anil"); + + Iterator itertator = list.iterator(); + + while(itertator.hasNext()) { + String value = itertator.next(); + System.out.println("--- "+value+" ---"); + + if(value.contains("Rahul")) { + System.out.println("Available"); + }else { + System.out.println("not Available"); + } + + } + // print using enhanced or loop + for(String lists : list) { + if(lists.contains("Rahul")) { + System.out.println(lists+" Final Result"); + } + System.out.println(lists); + } + } +} diff --git a/ImportantProgram/src/com/akash/serializations/ClientTest.java b/ImportantProgram/src/com/akash/serializations/ClientTest.java new file mode 100644 index 0000000..9f874cd --- /dev/null +++ b/ImportantProgram/src/com/akash/serializations/ClientTest.java @@ -0,0 +1,51 @@ +package com.akash.serializations; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +public class ClientTest { + + public static void main(String[] args) { + + String filename = "employee.ser"; + + //serializeObject(filename); + deSerializeObject(filename); + } + + private static void deSerializeObject(String filename) { + // TODO + try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File(filename)))){ + Object object = ois.readObject(); + Employee employee = (Employee)object; + System.out.println("Employee Object is deserialized ..."); + System.out.println("ID : "+ employee.getId()); + System.out.println("NAME : "+ employee.getName()); + System.out.println("Email : "+ employee.getEmail()); + + }catch (Exception e) { + // TODO: handle exception + } + + } + + private static void serializeObject(String filename) { + // TODO + Employee employee = new Employee(); + employee.setId(1001); + employee.setName("Akash Kumar"); + employee.setEmail("akash3662@gmail.com"); + try (ObjectOutputStream oob = new ObjectOutputStream(new FileOutputStream(new File(filename)))){ + oob.writeObject(employee); + System.out.println("Employee Object is Serialized"); + }catch(Exception e) { + System.out.println(e.getMessage()); + } + + } + +} diff --git a/ImportantProgram/src/com/akash/serializations/Employee.java b/ImportantProgram/src/com/akash/serializations/Employee.java new file mode 100644 index 0000000..d4f3065 --- /dev/null +++ b/ImportantProgram/src/com/akash/serializations/Employee.java @@ -0,0 +1,33 @@ +package com.akash.serializations; + +import java.io.Serializable; + +public class Employee implements Serializable{ + + private int id; + private String name; + private String email; + + + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + + + +} diff --git a/ImportantProgram/src/com/akash/serilization/Demo.java b/ImportantProgram/src/com/akash/serilization/Demo.java new file mode 100644 index 0000000..56a1586 --- /dev/null +++ b/ImportantProgram/src/com/akash/serilization/Demo.java @@ -0,0 +1,34 @@ +package com.akash.serilization; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +public class Demo { + + public static void main(String[] args) throws IOException { + // TODO Serialization + FileOutputStream fos = new FileOutputStream("text.txt"); + + ObjectOutputStream oos = new ObjectOutputStream(fos); + System.out.println(oos); + Employee emp = new Employee(); + oos.writeObject(emp); + + // TODO DeSerialization + FileInputStream fis = new FileInputStream("text.txt"); + ObjectInputStream ois = new ObjectInputStream(fis); + System.out.println(ois); + try { + Employee emp1 = (Employee)ois.readObject(); + System.out.println(emp1); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/ImportantProgram/src/com/akash/serilization/Employee.java b/ImportantProgram/src/com/akash/serilization/Employee.java new file mode 100644 index 0000000..93317a0 --- /dev/null +++ b/ImportantProgram/src/com/akash/serilization/Employee.java @@ -0,0 +1,22 @@ +package com.akash.serilization; + +import java.io.Serializable; + +public class Employee implements Cloneable, Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + public int empId = 105; + + public Employee() { + System.out.println("Employee class "); + } + + @Override + protected Object clone() throws CloneNotSupportedException { + // TODO + return super.clone(); + } +} \ No newline at end of file diff --git a/ImportantProgram/src/com/akash/stringImmutable/StringClassImmutableHashCode.java b/ImportantProgram/src/com/akash/stringImmutable/StringClassImmutableHashCode.java new file mode 100644 index 0000000..5f68708 --- /dev/null +++ b/ImportantProgram/src/com/akash/stringImmutable/StringClassImmutableHashCode.java @@ -0,0 +1,20 @@ +package com.akash.stringImmutable; + +public class StringClassImmutableHashCode { + + public static void main(String[] args) { + // TODO + String str = "Akki"; + str="kumar"; + String s = new String("Akki"); + String s2 = s; + System.out.println(s2); + + System.out.println(str); + str.hashCode(); + str.hashCode(); + System.out.println(str); + + } + +} diff --git a/ImportantProgram/src/com/akash/validateEmail/EmailValidate.java b/ImportantProgram/src/com/akash/validateEmail/EmailValidate.java new file mode 100644 index 0000000..6c7e348 --- /dev/null +++ b/ImportantProgram/src/com/akash/validateEmail/EmailValidate.java @@ -0,0 +1,34 @@ +package com.akash.validateEmail; + +import java.util.regex.Pattern; + +public class EmailValidate { + + public static void main(String[] args) { + // TODO + + String email = "akash36@gmail.com"; + + if(isvalid(email)) { + System.out.println("Yes, Validate"); + }else { + System.out.println("Not, Validate"); + } + + } + + private static boolean isvalid(String email) { + // TODO + String emailRegax = "^[a-zA-Z0-9_+&*-]+(?:\\."+ + "[a-zA-Z0-9_+&*-]+)*@"+"(?:[a-zA-Z0-9-]+\\.)" + + "+[a-z"+"A-Z] {2,7}$"; + + Pattern pattern = Pattern.compile(emailRegax); + if(email == null) { + return false; + } + return pattern.matcher(email).matches(); + + } + +} diff --git a/Java8Program/src/com/akash/eightJava/DefaultAExample.java b/Java8Program/src/com/akash/eightJava/DefaultAExample.java new file mode 100644 index 0000000..f8e9a52 --- /dev/null +++ b/Java8Program/src/com/akash/eightJava/DefaultAExample.java @@ -0,0 +1,9 @@ +package com.akash.eightJava; + +public interface DefaultAExample { + + default void m1() { + System.out.println("It Default A Class"); + } + +} diff --git a/Java8Program/src/com/akash/eightJava/DefaultBExample.java b/Java8Program/src/com/akash/eightJava/DefaultBExample.java new file mode 100644 index 0000000..4dcb3dc --- /dev/null +++ b/Java8Program/src/com/akash/eightJava/DefaultBExample.java @@ -0,0 +1,15 @@ +package com.akash.eightJava; + +public interface DefaultBExample { + + default void m1() { + System.out.println("It Default B Class is method M1"); + } + default void m2() { + System.out.println("It Default B Class is method M2"); + } + default void m3() { + System.out.println("It Default B Class is method M3"); + } + +} diff --git a/Java8Program/src/com/akash/eightJava/Example.java b/Java8Program/src/com/akash/eightJava/Example.java new file mode 100644 index 0000000..4faa077 --- /dev/null +++ b/Java8Program/src/com/akash/eightJava/Example.java @@ -0,0 +1,17 @@ +package com.akash.eightJava; + +public class Example { + + +public interface InterfaceA { + default void defaultMethod(){ + System.out.println("Interface A default method"); + } +} +public interface InterfaceB { + default void defaultMethod(){ + System.out.println("Interface B default method"); + } +} + +} diff --git a/Java8Program/src/com/akash/eightJava/MainRunner.java b/Java8Program/src/com/akash/eightJava/MainRunner.java new file mode 100644 index 0000000..7114caf --- /dev/null +++ b/Java8Program/src/com/akash/eightJava/MainRunner.java @@ -0,0 +1,16 @@ +package com.akash.eightJava; + +public class MainRunner implements DefaultAExample, DefaultBExample { + + + public static void main(String[] args) { + new MainRunner().m1(); + } + + @Override + public void m1() { + DefaultAExample.super.m1(); + DefaultBExample.super.m1(); + } + +} diff --git a/MultithreadingExample/.classpath b/MultithreadingExample/.classpath new file mode 100644 index 0000000..e461bea --- /dev/null +++ b/MultithreadingExample/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/MultithreadingExample/.project b/MultithreadingExample/.project new file mode 100644 index 0000000..bdd1f81 --- /dev/null +++ b/MultithreadingExample/.project @@ -0,0 +1,17 @@ + + + MultithreadingExample + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/MultithreadingExample/.settings/org.eclipse.jdt.core.prefs b/MultithreadingExample/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/MultithreadingExample/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/MultithreadingExample/src/com/akash/begin/MultiThreadingExtending.java b/MultithreadingExample/src/com/akash/begin/MultiThreadingExtending.java new file mode 100644 index 0000000..c59bd1c --- /dev/null +++ b/MultithreadingExample/src/com/akash/begin/MultiThreadingExtending.java @@ -0,0 +1,17 @@ +package com.akash.begin; + +public class MultiThreadingExtending extends Thread { + + public void run() { + System.out.println("Thread is running"); + } + + public static void main(String[] args) { + MultiThreadingExtending multiThreadingExtending = new MultiThreadingExtending(); + multiThreadingExtending.start(); + } + + + + +} diff --git a/MultithreadingExample/src/com/akash/begin/ThreadImplement.java b/MultithreadingExample/src/com/akash/begin/ThreadImplement.java new file mode 100644 index 0000000..ec47a5d --- /dev/null +++ b/MultithreadingExample/src/com/akash/begin/ThreadImplement.java @@ -0,0 +1,15 @@ +package com.akash.begin; + +public class ThreadImplement implements Runnable{ + + public void run() { + System.out.println("Thread is running......."); + } + + public static void main(String[] args) { + // TODO + ThreadImplement threadImplement = new ThreadImplement(); + Thread thread = new Thread(threadImplement); + thread.start(); + } +} \ No newline at end of file diff --git a/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelBlock.java b/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelBlock.java new file mode 100644 index 0000000..c221ca0 --- /dev/null +++ b/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelBlock.java @@ -0,0 +1,11 @@ +package com.akash.classLevelLock; + +public class ClassLevelBlock { + + public void demoMethod() { + // Acquire lock on .class level + synchronized (ClassLevelBlock.class) { + //other thread safe + } + } +} \ No newline at end of file diff --git a/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelLock.java b/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelLock.java new file mode 100644 index 0000000..257aaa1 --- /dev/null +++ b/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelLock.java @@ -0,0 +1,8 @@ +package com.akash.classLevelLock; + +public class ClassLevelLock { + + // Method is static + public synchronized static void demoMethod() {} + +} \ No newline at end of file diff --git a/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelinstance.java b/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelinstance.java new file mode 100644 index 0000000..11149a5 --- /dev/null +++ b/MultithreadingExample/src/com/akash/classLevelLock/ClassLevelinstance.java @@ -0,0 +1,14 @@ +package com.akash.classLevelLock; + +public class ClassLevelinstance { + + private final static Object lock= new Object(); + + public void demoMethod() { + synchronized (lock) + { + // other thread safe code..... + } + } + +} diff --git a/MultithreadingExample/src/com/akash/deadLock/AvoidDeadLock.java b/MultithreadingExample/src/com/akash/deadLock/AvoidDeadLock.java new file mode 100644 index 0000000..9477386 --- /dev/null +++ b/MultithreadingExample/src/com/akash/deadLock/AvoidDeadLock.java @@ -0,0 +1,27 @@ +package com.akash.deadLock; + +public class AvoidDeadLock { + public static void main(String[] args) { + //method1(); + } + + public void method1() { + synchronized (Integer.class) { + System.out.println("Acquire lock on Integer.class object"); + synchronized (String.class) { + System.out.println("Acquire lock on String.class object"); + } + } + + } + + public void method2() { + synchronized (Integer.class) { + System.out.println("Acquire lock on Integer.class object"); + synchronized (String.class) { + System.out.println("Acquire lock on String.class object"); + } + } + } + +} diff --git a/MultithreadingExample/src/com/akash/deadLock/ResultDeadLock.java b/MultithreadingExample/src/com/akash/deadLock/ResultDeadLock.java new file mode 100644 index 0000000..61d6520 --- /dev/null +++ b/MultithreadingExample/src/com/akash/deadLock/ResultDeadLock.java @@ -0,0 +1,26 @@ +package com.akash.deadLock; + +public class ResultDeadLock { + + public static void main(String[] args) { + method1(); + method2(); + } + public static void method1() { + synchronized (String.class) { + System.out.println("Acquire lock on String.class object M1"); + synchronized(Integer.class) { + System.out.println("Acquire lock on Integer.class object M1"); + } + } + } + + public static void method2() { + synchronized (Integer.class) { + System.out.println("Acquire lock on Integer.class object M2"); + synchronized (String.class) { + System.out.println("Acquire lock on String.class object M2"); + } + } + } +} \ No newline at end of file diff --git a/MultithreadingExample/src/com/akash/exception/X.java b/MultithreadingExample/src/com/akash/exception/X.java new file mode 100644 index 0000000..befe50d --- /dev/null +++ b/MultithreadingExample/src/com/akash/exception/X.java @@ -0,0 +1,23 @@ +package com.akash.exception; + +public class X { + + public static void main(String[] args) { + //badMethod(); + int a = 10; + change(a); + System.out.println(a); + System.out.println("C"); + } + + private static void change(int a) { + + a = 20; + + } + + + + + +} diff --git a/MultithreadingExample/src/com/akash/lock/ObjectLock.java b/MultithreadingExample/src/com/akash/lock/ObjectLock.java new file mode 100644 index 0000000..588a095 --- /dev/null +++ b/MultithreadingExample/src/com/akash/lock/ObjectLock.java @@ -0,0 +1,8 @@ +package com.akash.lock; + +public class ObjectLock { + + public synchronized void demoMethod() {} + +} + diff --git a/MultithreadingExample/src/com/akash/lock/ObjectLockOther.java b/MultithreadingExample/src/com/akash/lock/ObjectLockOther.java new file mode 100644 index 0000000..cbdcea1 --- /dev/null +++ b/MultithreadingExample/src/com/akash/lock/ObjectLockOther.java @@ -0,0 +1,18 @@ +package com.akash.lock; + +public class ObjectLockOther { + + private final Object lock = new Object(); + + public void demoMethod() { + synchronized(lock) { + //Other thread safe + } + } + + public static void main(String[] args) { + + System.out.println("HEllo"); + } + +} diff --git a/MultithreadingExample/src/com/akash/lock/ObjectLockThreadSafe.java b/MultithreadingExample/src/com/akash/lock/ObjectLockThreadSafe.java new file mode 100644 index 0000000..791f359 --- /dev/null +++ b/MultithreadingExample/src/com/akash/lock/ObjectLockThreadSafe.java @@ -0,0 +1,10 @@ +package com.akash.lock; + +public class ObjectLockThreadSafe { + + public void demoMethod() { + synchronized (this) { + // Other thread safe + } + } +} \ No newline at end of file diff --git a/OppsConcepts/.classpath b/OppsConcepts/.classpath new file mode 100644 index 0000000..e461bea --- /dev/null +++ b/OppsConcepts/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/OppsConcepts/.project b/OppsConcepts/.project new file mode 100644 index 0000000..4ae6640 --- /dev/null +++ b/OppsConcepts/.project @@ -0,0 +1,17 @@ + + + OppsConcepts + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/OppsConcepts/.settings/org.eclipse.jdt.core.prefs b/OppsConcepts/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/OppsConcepts/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/OppsConcepts/src/com/akash/abstractClass/AbstractDemo.java b/OppsConcepts/src/com/akash/abstractClass/AbstractDemo.java new file mode 100644 index 0000000..7e7ae85 --- /dev/null +++ b/OppsConcepts/src/com/akash/abstractClass/AbstractDemo.java @@ -0,0 +1,8 @@ +package com.akash.abstractClass; + +public abstract class AbstractDemo { + + int i ; + int j; + +} diff --git a/OppsConcepts/src/com/akash/abstractClass/ContainConstructor.java b/OppsConcepts/src/com/akash/abstractClass/ContainConstructor.java new file mode 100644 index 0000000..14b8a47 --- /dev/null +++ b/OppsConcepts/src/com/akash/abstractClass/ContainConstructor.java @@ -0,0 +1,9 @@ +package com.akash.abstractClass; + +public class ContainConstructor extends AbstractDemo{ + + public static void main(String[] args) { + + } + +} diff --git a/OppsConcepts/src/com/akash/abstractfinal/Bank.java b/OppsConcepts/src/com/akash/abstractfinal/Bank.java new file mode 100644 index 0000000..b28841e --- /dev/null +++ b/OppsConcepts/src/com/akash/abstractfinal/Bank.java @@ -0,0 +1,8 @@ +package com.akash.abstractfinal; + +public interface Bank{ + + void credit(); + void save(); + +} diff --git a/OppsConcepts/src/com/akash/abstractfinal/Sbi.java b/OppsConcepts/src/com/akash/abstractfinal/Sbi.java new file mode 100644 index 0000000..c1bca11 --- /dev/null +++ b/OppsConcepts/src/com/akash/abstractfinal/Sbi.java @@ -0,0 +1,8 @@ +package com.akash.abstractfinal; + +public abstract class Sbi implements Bank { + + + + +} \ No newline at end of file diff --git a/OppsConcepts/src/com/akash/abstraction/Circle.java b/OppsConcepts/src/com/akash/abstraction/Circle.java new file mode 100644 index 0000000..f9e8346 --- /dev/null +++ b/OppsConcepts/src/com/akash/abstraction/Circle.java @@ -0,0 +1,26 @@ +package com.akash.abstraction; + +public class Circle extends Shape{ + + double radius; + + public Circle(String color, double radius){ + super(color); + System.out.println("Circle Constructor "); + this.radius = radius; + } + + @Override + double area() { + // TODO Auto-generated method stub + return Math.PI * Math.pow(radius, 2); + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return "Circle color is " + super.color + + "and area is : " + area(); + } + +} \ No newline at end of file diff --git a/OppsConcepts/src/com/akash/abstraction/Rectangle.java b/OppsConcepts/src/com/akash/abstraction/Rectangle.java new file mode 100644 index 0000000..ca1326e --- /dev/null +++ b/OppsConcepts/src/com/akash/abstraction/Rectangle.java @@ -0,0 +1,28 @@ +package com.akash.abstraction; + +public class Rectangle extends Shape { + + double length; + double width; + + public Rectangle(String color, double length, double width) { + super(color); + this.length = length; + this.width = width; + System.out.println("Rectangle Constructor "); + // TODO + } + + @Override + double area() { + // TODO + return length*width; + } + + @Override + public String toString() { + // TODO + return "Rectangle color is " + super.color + + "and area is : " + area(); + } +} \ No newline at end of file diff --git a/OppsConcepts/src/com/akash/abstraction/Runner.java b/OppsConcepts/src/com/akash/abstraction/Runner.java new file mode 100644 index 0000000..848dfd9 --- /dev/null +++ b/OppsConcepts/src/com/akash/abstraction/Runner.java @@ -0,0 +1,16 @@ +package com.akash.abstraction; + +public class Runner { + + public static void main(String[] args) { + + Shape s1 = new Circle("Red", 4.5); + s1.area(); + /* + * Shape Constructor called Circle Constructor + */ + Shape s2 = new Rectangle("Red", 55, 12); + s2.area(); + + } +} \ No newline at end of file diff --git a/OppsConcepts/src/com/akash/abstraction/Shape.java b/OppsConcepts/src/com/akash/abstraction/Shape.java new file mode 100644 index 0000000..0e0a68a --- /dev/null +++ b/OppsConcepts/src/com/akash/abstraction/Shape.java @@ -0,0 +1,21 @@ +package com.akash.abstraction; + +public abstract class Shape { + + String color; + + abstract double area(); + + public abstract String toString(); + + public Shape(String color){ + this.color = color; + System.out.println("Shape Constructor called"); + } + + public String getColor() { + return color; + } + + +} diff --git a/OppsConcepts/src/com/akash/abstracts/Abc.java b/OppsConcepts/src/com/akash/abstracts/Abc.java new file mode 100644 index 0000000..51c04e8 --- /dev/null +++ b/OppsConcepts/src/com/akash/abstracts/Abc.java @@ -0,0 +1,10 @@ +package com.akash.abstracts; + +public class Abc extends Bcd{ + + @Override + public void go() { + + } + +} diff --git a/OppsConcepts/src/com/akash/abstracts/Bcd.java b/OppsConcepts/src/com/akash/abstracts/Bcd.java new file mode 100644 index 0000000..c813854 --- /dev/null +++ b/OppsConcepts/src/com/akash/abstracts/Bcd.java @@ -0,0 +1,16 @@ +package com.akash.abstracts; + +public abstract class Bcd { + + public abstract void go(); + + public void getFood() { + + } + + public String hello(){ + + return ""; + } + +} diff --git a/OppsConcepts/src/com/akash/equalsHashCode/TestHashEquals.java b/OppsConcepts/src/com/akash/equalsHashCode/TestHashEquals.java new file mode 100644 index 0000000..0dbd5e4 --- /dev/null +++ b/OppsConcepts/src/com/akash/equalsHashCode/TestHashEquals.java @@ -0,0 +1,26 @@ +package com.akash.equalsHashCode; + +public class TestHashEquals { + + public static void main(String[] args) { + String s = "Akash"; + String s1 = new String("Akash"); + String s2 = new String("Hello"); + + System.out.println("hashCode S :: "+ s.hashCode()); + System.out.println("hashCode S1 : "+s1.hashCode()); + System.out.println("hashCode S2 : "+s2.hashCode()); + + System.out.println("Equals Example S1 and S2 : "+ s1.equals(s2)); + System.out.println("Equals Example S and S2 : "+ s.equals(s2)); + + System.out.println("Equals S AND S1 : "+ s.equals(s1)); + + System.out.println("Are Equals s == S1: "+ s == s1); + + System.out.println("Are Equals S1==S2 : "+ s1==s2); + System.out.println("Are Equals S2==s1 :"+ s2==s1); + + } + +} diff --git a/OppsConcepts/src/com/akash/hashCodeAndEquals/HashCodeAndEquals.java b/OppsConcepts/src/com/akash/hashCodeAndEquals/HashCodeAndEquals.java new file mode 100644 index 0000000..afac978 --- /dev/null +++ b/OppsConcepts/src/com/akash/hashCodeAndEquals/HashCodeAndEquals.java @@ -0,0 +1,65 @@ +package com.akash.hashCodeAndEquals; + +import java.util.HashMap; +import java.util.Map; + +public class HashCodeAndEquals { + + public static void main(String[] args) { + // TODO + Employee e1= new Employee(1); + Employee e2= new Employee(1); + + Map map = new HashMap(); + map.put(e1, "1"); + map.put(e2, "1"); + + Map hmap = new HashMap<>(); + hmap.put("Akash", 25); + hmap.put("Ravi", 25); + + System.out.println("HMap :: "+hmap.size()); + + System.out.println(map.size()); // guess it + System.out.println(map.entrySet()); //convert list + + // clue + Integer i1 = new Integer(1); + Integer i2 = new Integer(1); + Map map1 = new HashMap<>(); + map1.put(i1, "one"); + map1.put(i2, "one"); + + System.out.println(map1.size()); // output // 1 + } +} +class Employee{ + int id; + + public Employee(int id) { + this.id=id; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + id; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Employee other = (Employee) obj; + if (id != other.id) + return false; + return true; + } + +} diff --git a/OppsConcepts/src/com/akash/immutableClass/FinalClassExample.java b/OppsConcepts/src/com/akash/immutableClass/FinalClassExample.java new file mode 100644 index 0000000..e48aade --- /dev/null +++ b/OppsConcepts/src/com/akash/immutableClass/FinalClassExample.java @@ -0,0 +1,26 @@ +package com.akash.immutableClass; + +public final class FinalClassExample { + + private final int id; + private final String name; + + public FinalClassExample(String name, int id) { + this.name = name; + this.id = id; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public static void main(String[] args) { + FinalClassExample finalClass = new FinalClassExample("Akash", 5); + System.out.println(finalClass.getName()); + System.out.println(finalClass.getId()); + } +} \ No newline at end of file diff --git a/OppsConcepts/src/com/akash/inher/Animal.java b/OppsConcepts/src/com/akash/inher/Animal.java new file mode 100644 index 0000000..7dddb01 --- /dev/null +++ b/OppsConcepts/src/com/akash/inher/Animal.java @@ -0,0 +1,9 @@ +package com.akash.inher; + +public class Animal { + String x = "Animal Literal Variable"; + static String staticX = "Animal Static Variable"; + void getMsg() { + System.out.println("Animal class"); + } +} diff --git a/OppsConcepts/src/com/akash/inher/Dog.java b/OppsConcepts/src/com/akash/inher/Dog.java new file mode 100644 index 0000000..eb0ad09 --- /dev/null +++ b/OppsConcepts/src/com/akash/inher/Dog.java @@ -0,0 +1,12 @@ +package com.akash.inher; + + + +public class Dog extends Animal{ + String x = "Dog Literal Variable"; + static String staticX = "Dog Static Variable"; + + void getMsg() { + System.out.println("Dog Lession class "); + } +} diff --git a/OppsConcepts/src/com/akash/inher/Runner.java b/OppsConcepts/src/com/akash/inher/Runner.java new file mode 100644 index 0000000..2a13e08 --- /dev/null +++ b/OppsConcepts/src/com/akash/inher/Runner.java @@ -0,0 +1,28 @@ +package com.akash.inher; + + +public class Runner { + + public static void main(String[] args) { + + Animal animal = new Animal(); + animal.getMsg(); /*Animal*/ + System.out.println("Animal: "+animal.x); /*Animal*/ + System.out.println("---- Animal class as Dog -----"); /*Animal*/ + + Animal animal1 = new Dog(); + animal1.getMsg(); /*Dog class*/ + System.out.println("Animal Object : "+animal1.x); /*refer Animal class*/ + System.out.println("Animal Static : "+Animal.staticX); /*refer Animal*/ + + Dog dog = new Dog(); + dog.getMsg(); /*dog*/ + + System.out.println("Dog liter: "+dog.x); /*dog*/ + System.out.println("Dog Static : "+Dog.staticX); /*dog*/ + + //Dog dog1 =(Dog) new Animal(); + //dog1.getMsg(); + //System.out.println("wide "+dog1.x); + } +} diff --git a/OppsConcepts/src/com/akash/inheriDemo/Child.java b/OppsConcepts/src/com/akash/inheriDemo/Child.java new file mode 100644 index 0000000..81c7e8d --- /dev/null +++ b/OppsConcepts/src/com/akash/inheriDemo/Child.java @@ -0,0 +1,12 @@ +package com.akash.inheriDemo; + +abstract class Child extends Parent implements MyInterface{ + + public void method() { + // do code + } + + public abstract void method2(); + + +} diff --git a/OppsConcepts/src/com/akash/inheriDemo/MyInterface.java b/OppsConcepts/src/com/akash/inheriDemo/MyInterface.java new file mode 100644 index 0000000..5173c7a --- /dev/null +++ b/OppsConcepts/src/com/akash/inheriDemo/MyInterface.java @@ -0,0 +1,24 @@ +package com.akash.inheriDemo; + + interface MyInterface { + + + class Interfacehdh implements MyInterface{ + + + @Override + public void method1() { + // TODO + System.out.println("hello heuuun method 1"); + } + + @Override + public void method2() { + // TODO + System.out.println("hello Method 2 "); + } + } + void method1(); + void method2(); + +} diff --git a/OppsConcepts/src/com/akash/inheriDemo/Parent.java b/OppsConcepts/src/com/akash/inheriDemo/Parent.java new file mode 100644 index 0000000..68d59d7 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheriDemo/Parent.java @@ -0,0 +1,8 @@ +package com.akash.inheriDemo; + +public abstract class Parent implements MyInterface{ + + abstract public void method1(); + + +} diff --git a/OppsConcepts/src/com/akash/inheriDemo/Runner.java b/OppsConcepts/src/com/akash/inheriDemo/Runner.java new file mode 100644 index 0000000..3077cca --- /dev/null +++ b/OppsConcepts/src/com/akash/inheriDemo/Runner.java @@ -0,0 +1,32 @@ +package com.akash.inheriDemo; + +public class Runner implements MyInterface { + + class Inner{ + void msg() { + System.out.println("hellp"); + } + } + + public static void main(String[] args) { + Runner.Inner in = new Runner().new Inner(); + in.msg(); /*method called*/ + Interfacehdh in2 = new Interfacehdh(); + in2.method1(); + in2.method2(); + } + + + @Override + public void method1() { + // TODO Auto-generated method stub + + } + + @Override + public void method2() { + // TODO Auto-generated method stub + + } + +} diff --git a/OppsConcepts/src/com/akash/inheriDemo/SubChild.java b/OppsConcepts/src/com/akash/inheriDemo/SubChild.java new file mode 100644 index 0000000..f09ec93 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheriDemo/SubChild.java @@ -0,0 +1,17 @@ +package com.akash.inheriDemo; + +public class SubChild implements MyInterface{ + + @Override + public void method1() { + // TODO + System.out.println("Method 1"); + } + + @Override + public void method2() { + // TODO + System.out.println("Method 2"); + } + +} diff --git a/OppsConcepts/src/com/akash/inheriThrow/Abc.java b/OppsConcepts/src/com/akash/inheriThrow/Abc.java new file mode 100644 index 0000000..b64ae53 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheriThrow/Abc.java @@ -0,0 +1,9 @@ +package com.akash.inheriThrow; + +public class Abc { + + void m1() { + System.out.println("Method 1 ABC"); + } + +} diff --git a/OppsConcepts/src/com/akash/inheriThrow/Bcd.java b/OppsConcepts/src/com/akash/inheriThrow/Bcd.java new file mode 100644 index 0000000..93abb98 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheriThrow/Bcd.java @@ -0,0 +1,17 @@ +package com.akash.inheriThrow; + +public class Bcd extends Abc{ + + @Override + void m1() { + // TODO + System.out.println("M1 in BCD class"); + + } + + void m2() { + // TODO Auto-generated method stub + System.out.println("M2 in BCD class"); + } + +} diff --git a/OppsConcepts/src/com/akash/inheriThrow/Runner.java b/OppsConcepts/src/com/akash/inheriThrow/Runner.java new file mode 100644 index 0000000..bd491e0 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheriThrow/Runner.java @@ -0,0 +1,10 @@ +package com.akash.inheriThrow; + +public class Runner { + + public static void main(String[] args) { + Abc a = new Bcd(); + a.m1(); // BCD class + } + +} diff --git a/OppsConcepts/src/com/akash/inheritanceDemo/ChildDemo.java b/OppsConcepts/src/com/akash/inheritanceDemo/ChildDemo.java new file mode 100644 index 0000000..85cf7d9 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritanceDemo/ChildDemo.java @@ -0,0 +1,8 @@ +package com.akash.inheritanceDemo; + +public class ChildDemo extends InheritanceDemo { + + public ChildDemo() { + count++; + } +} diff --git a/OppsConcepts/src/com/akash/inheritanceDemo/InheritanceDemo.java b/OppsConcepts/src/com/akash/inheritanceDemo/InheritanceDemo.java new file mode 100644 index 0000000..5c31f10 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritanceDemo/InheritanceDemo.java @@ -0,0 +1,13 @@ +package com.akash.inheritanceDemo; + +public class InheritanceDemo { + + protected static int count = 0; + public InheritanceDemo() { + count++; + } + static int getCount() { + return count; + } + +} diff --git a/OppsConcepts/src/com/akash/inheritanceDemo/Runner.java b/OppsConcepts/src/com/akash/inheritanceDemo/Runner.java new file mode 100644 index 0000000..72ade7d --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritanceDemo/Runner.java @@ -0,0 +1,15 @@ +package com.akash.inheritanceDemo; + +public class Runner { + + public static void main(String[] args) { + // TODO + System.out.println("hello"); + System.out.println("Count : "+ ChildDemo.getCount()); + + ChildDemo chiledDemo = new ChildDemo(); + chiledDemo.toString(); + System.out.println("Count : "+ ChildDemo.getCount()); + } + +} diff --git a/OppsConcepts/src/com/akash/inheritanceExam/Child.java b/OppsConcepts/src/com/akash/inheritanceExam/Child.java new file mode 100644 index 0000000..46cee29 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritanceExam/Child.java @@ -0,0 +1,10 @@ +package com.akash.inheritanceExam; + +public class Child extends Parent{ + + int x = 10; + void msg() { + System.out.println("Child class of x value is 10"); + } + +} diff --git a/OppsConcepts/src/com/akash/inheritanceExam/Parent.java b/OppsConcepts/src/com/akash/inheritanceExam/Parent.java new file mode 100644 index 0000000..b987f36 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritanceExam/Parent.java @@ -0,0 +1,14 @@ +package com.akash.inheritanceExam; + +public class Parent { + + void heloo() { + System.out.println("Parent class of hello"); + } + + int x = 5; + void msg() { + System.out.println("Parent class Of x value is 5"); + } + +} diff --git a/OppsConcepts/src/com/akash/inheritanceExam/Runner.java b/OppsConcepts/src/com/akash/inheritanceExam/Runner.java new file mode 100644 index 0000000..523151e --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritanceExam/Runner.java @@ -0,0 +1,27 @@ +package com.akash.inheritanceExam; + +public class Runner { + + public static void main(String[] args) { + + Parent p = new Parent(); + p.msg(); + p.heloo(); + System.out.println( "Parent P : "+p.x); + + Parent p1 = new Child(); + p1.msg(); + p1.heloo(); + System.out.println("Parent P1 : "+p1.x); + + Child c = new Child(); + c.msg(); + c.heloo(); + System.out.println("Child C : " +c.x); + + /*Child child = (Child) new Parent(); + child.msg(); + System.out.println("Child child "+child.x);*/ + } + +} diff --git a/OppsConcepts/src/com/akash/inheritancestatic/A.java b/OppsConcepts/src/com/akash/inheritancestatic/A.java new file mode 100644 index 0000000..328d155 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritancestatic/A.java @@ -0,0 +1,16 @@ +package com.akash.inheritancestatic; + +public class A { + + { + System.out.println("Instance Block of A Parent Class"); + } + static { + System.out.println("Static block in A class Parent Class"); + } + + public A() { + // TODO + System.out.println("Constructor in A Parent Class"); + } +} \ No newline at end of file diff --git a/OppsConcepts/src/com/akash/inheritancestatic/B.java b/OppsConcepts/src/com/akash/inheritancestatic/B.java new file mode 100644 index 0000000..825b8f1 --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritancestatic/B.java @@ -0,0 +1,16 @@ +package com.akash.inheritancestatic; + +public class B extends A{ + + { + System.out.println("Instance Block of B"); + } + static { + System.out.println("Static block in B class"); + } + + public B() { + System.out.println("Constrictor in B"); + } + +} diff --git a/OppsConcepts/src/com/akash/inheritancestatic/MainMethod.java b/OppsConcepts/src/com/akash/inheritancestatic/MainMethod.java new file mode 100644 index 0000000..ee7e1eb --- /dev/null +++ b/OppsConcepts/src/com/akash/inheritancestatic/MainMethod.java @@ -0,0 +1,18 @@ +package com.akash.inheritancestatic; + +public class MainMethod { + + public static void main(String[] args) { + // TODO + + A b = new B(); + System.out.println(b); + + System.out.println("------------"); + + A a = new A(); + System.out.println(a); + + } + +} diff --git a/OppsConcepts/src/com/akash/inhertanceDemo/DemoA.java b/OppsConcepts/src/com/akash/inhertanceDemo/DemoA.java new file mode 100644 index 0000000..a40be67 --- /dev/null +++ b/OppsConcepts/src/com/akash/inhertanceDemo/DemoA.java @@ -0,0 +1,9 @@ +package com.akash.inhertanceDemo; + +public class DemoA { + + public static void m1() { + System.out.println("DemoA is method m1"); + } + +} diff --git a/OppsConcepts/src/com/akash/inhertanceDemo/DemoB.java b/OppsConcepts/src/com/akash/inhertanceDemo/DemoB.java new file mode 100644 index 0000000..9a2a368 --- /dev/null +++ b/OppsConcepts/src/com/akash/inhertanceDemo/DemoB.java @@ -0,0 +1,9 @@ +package com.akash.inhertanceDemo; + +public class DemoB extends DemoA{ + + static void m2() { + System.out.println("M2 Method are available"); + } + +} diff --git a/OppsConcepts/src/com/akash/inhertanceDemo/Runner.java b/OppsConcepts/src/com/akash/inhertanceDemo/Runner.java new file mode 100644 index 0000000..f5fbaf5 --- /dev/null +++ b/OppsConcepts/src/com/akash/inhertanceDemo/Runner.java @@ -0,0 +1,10 @@ +package com.akash.inhertanceDemo; + +public class Runner { + + public static void main(String[] args) { + DemoB b = new DemoB(); + b.m1(); + } + +} diff --git a/OppsConcepts/src/com/akash/instanceInitail/ConstructorInitial.java b/OppsConcepts/src/com/akash/instanceInitail/ConstructorInitial.java new file mode 100644 index 0000000..f49e656 --- /dev/null +++ b/OppsConcepts/src/com/akash/instanceInitail/ConstructorInitial.java @@ -0,0 +1,38 @@ +package com.akash.instanceInitail; + +public class ConstructorInitial { + + //Every call object then call instance block + // but static block call only once when call every time object + // initial block start.... + static{ + int i=0; + System.out.println("Static block"+i); + } + + { + System.out.println("initial instance block...."); + } + + public ConstructorInitial(int j) { + System.out.println("hey i am int parameterized constructor"+ j); + } + public ConstructorInitial(){ + System.out.println("default constructor"); + } + public ConstructorInitial(String name){ + System.out.println("parametrized constructor " + name); + } + public static void main(String[] args) { + // TODO + + ConstructorInitial constructorInitial = new ConstructorInitial(); + System.out.println(constructorInitial); + ConstructorInitial constructorInitial2 = new ConstructorInitial(156); + System.out.println(constructorInitial2); + ConstructorInitial constructorInitial3 = new ConstructorInitial("String"); + System.out.println(constructorInitial3); + + } + +} diff --git a/OppsConcepts/src/com/akash/instanceInitail/InstanceBlock.java b/OppsConcepts/src/com/akash/instanceInitail/InstanceBlock.java new file mode 100644 index 0000000..ecc0b17 --- /dev/null +++ b/OppsConcepts/src/com/akash/instanceInitail/InstanceBlock.java @@ -0,0 +1,31 @@ +package com.akash.instanceInitail; + +public class InstanceBlock { + + { + // 2nd execute + System.out.println("instance Block....."); // 2nd + } + + static { + // 1st execute + System.out.println("hello i am static block"); // 1st + } + + public InstanceBlock() { + // 4rd execute + // TODO + System.out.println("hello i am constructor ..."); // 4rd + } + + { + // 3rd execute + System.out.println("hello I instance 2"); // 3rd + } + public static void main(String[] args) { + // TODO + InstanceBlock instanceBlock = new InstanceBlock(); + System.out.println("instance Object "+ instanceBlock); + } + +} diff --git a/OppsConcepts/src/com/akash/instanceInitail/StaticBlock.java b/OppsConcepts/src/com/akash/instanceInitail/StaticBlock.java new file mode 100644 index 0000000..440f08d --- /dev/null +++ b/OppsConcepts/src/com/akash/instanceInitail/StaticBlock.java @@ -0,0 +1,26 @@ +package com.akash.instanceInitail; + +public class StaticBlock { + + public static void main(String[] args) { + System.out.println("how to main method"); + new StaticBlock(); + System.out.println(new StaticBlock().j); + System.out.println(i); + } + static int i; + int j=20; + { + System.out.println("I am Instance"); + } + static{ + i =10; + System.out.println("static block is : "+ i); + } + + public StaticBlock() { + System.out.println("I am constructor"); + } + + +} diff --git a/OppsConcepts/src/com/akash/interfaceClass/Bank.java b/OppsConcepts/src/com/akash/interfaceClass/Bank.java new file mode 100644 index 0000000..c9a0e7a --- /dev/null +++ b/OppsConcepts/src/com/akash/interfaceClass/Bank.java @@ -0,0 +1,19 @@ +package com.akash.interfaceClass; + +public class Bank { + public static void main(String[] args) { + + RBI sbiuser = new SBI(); + sbiuser.deposits(); // SBI + sbiuser.withdraw(); // SBI + + RBI hdfc = new HDCF(); + hdfc.deposits(); //HDFC + hdfc.withdraw(); // HDFC + + RBI icici = new ICICI(); + icici.deposits(); // ICICI + icici.withdraw(); // ICICI + } + +} diff --git a/OppsConcepts/src/com/akash/interfaceClass/HDCF.java b/OppsConcepts/src/com/akash/interfaceClass/HDCF.java new file mode 100644 index 0000000..b813780 --- /dev/null +++ b/OppsConcepts/src/com/akash/interfaceClass/HDCF.java @@ -0,0 +1,17 @@ +package com.akash.interfaceClass; + +public class HDCF implements RBI{ + + @Override + public void withdraw() { + // TODO Auto-generated method stub + System.out.println("HDFC Withdraw"); + } + + @Override + public void deposits() { + // TODO Auto-generated method stub + System.out.println("HDFC deposit"); + } + +} diff --git a/OppsConcepts/src/com/akash/interfaceClass/ICICI.java b/OppsConcepts/src/com/akash/interfaceClass/ICICI.java new file mode 100644 index 0000000..80a5207 --- /dev/null +++ b/OppsConcepts/src/com/akash/interfaceClass/ICICI.java @@ -0,0 +1,17 @@ +package com.akash.interfaceClass; + +public class ICICI implements RBI{ + + @Override + public void withdraw() { + // TODO Auto-generated method stub + System.out.println("ICICI Withdraw"); + } + + @Override + public void deposits() { + // TODO Auto-generated method stub + System.out.println("ICICI deposit"); + } + +} diff --git a/OppsConcepts/src/com/akash/interfaceClass/RBI.java b/OppsConcepts/src/com/akash/interfaceClass/RBI.java new file mode 100644 index 0000000..44c53dc --- /dev/null +++ b/OppsConcepts/src/com/akash/interfaceClass/RBI.java @@ -0,0 +1,7 @@ +package com.akash.interfaceClass; + +public interface RBI { + void withdraw(); + void deposits(); + +} diff --git a/OppsConcepts/src/com/akash/interfaceClass/SBI.java b/OppsConcepts/src/com/akash/interfaceClass/SBI.java new file mode 100644 index 0000000..c30b5e0 --- /dev/null +++ b/OppsConcepts/src/com/akash/interfaceClass/SBI.java @@ -0,0 +1,17 @@ +package com.akash.interfaceClass; + +public class SBI implements RBI{ + + @Override + public void withdraw() { + // TODO + System.out.println("SBI Withdraw"); + } + + @Override + public void deposits() { + // TODO Auto-generated method stub + System.out.println("SBI deposit"); + } + +} diff --git a/OppsConcepts/src/com/akash/logic/A.java b/OppsConcepts/src/com/akash/logic/A.java new file mode 100644 index 0000000..e4e3b1f --- /dev/null +++ b/OppsConcepts/src/com/akash/logic/A.java @@ -0,0 +1,35 @@ +package com.akash.logic; + +public class A { + + void m1(Object b) { + + } + + void m1(String s) { + + } + + public static int m2(int d) { + int a=1; + int b=2; + int c=3; + try { + System.out.println("Hello"); + return a; + }catch(Exception e) { + return b; + }finally { + return c; + } + } + + public static void main(String[] args) { + + int i=m2(54); + System.out.println(i); + } + + + +} diff --git a/OppsConcepts/src/com/akash/logic/B.java b/OppsConcepts/src/com/akash/logic/B.java new file mode 100644 index 0000000..822d028 --- /dev/null +++ b/OppsConcepts/src/com/akash/logic/B.java @@ -0,0 +1,19 @@ +package com.akash.logic; + +public class B extends A{ + + @Override + public void m1(Object b) { + // TODO Auto-generated method stub + + } + + @Override + public void m1(String s) { + // TODO Auto-generated method stub + + } + + + +} diff --git a/OppsConcepts/src/com/akash/logic/Employee.java b/OppsConcepts/src/com/akash/logic/Employee.java new file mode 100644 index 0000000..8a2fdaa --- /dev/null +++ b/OppsConcepts/src/com/akash/logic/Employee.java @@ -0,0 +1,49 @@ +package com.akash.logic; + +public class Employee { + + private String employeeName; + private String employeeAddress; + + public String getEmployeeName() { + return employeeName; + } + public void setEmployeeName(String employeeName) { + this.employeeName = employeeName; + } + public String getEmployeeAddress() { + return employeeAddress; + } + public void setEmployeeAddress(String employeeAddress) { + this.employeeAddress = employeeAddress; + } + @Override + public String toString() { + return "Employee [employeeName=" + employeeName + ", employeeAddress=" + employeeAddress + "]"; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Employee other = (Employee) obj; + if (employeeAddress == null) { + if (other.employeeAddress != null) + return false; + } else if (!employeeAddress.equals(other.employeeAddress)) + return false; + if (employeeName == null) { + if (other.employeeName != null) + return false; + } else if (!employeeName.equals(other.employeeName)) + return false; + return true; + } + + + +} diff --git a/OppsConcepts/src/com/akash/logic/Runner.java b/OppsConcepts/src/com/akash/logic/Runner.java new file mode 100644 index 0000000..745ada5 --- /dev/null +++ b/OppsConcepts/src/com/akash/logic/Runner.java @@ -0,0 +1,15 @@ +package com.akash.logic; + +import java.util.HashMap; +import java.util.Map; + +public class Runner { + + public static void main(String[] args) { + + Map maap = new HashMap<>(); + + maap.put(new Employee(), ""); + } + +} diff --git a/OppsConcepts/src/com/akash/logical/A.java b/OppsConcepts/src/com/akash/logical/A.java new file mode 100644 index 0000000..c86ea90 --- /dev/null +++ b/OppsConcepts/src/com/akash/logical/A.java @@ -0,0 +1,11 @@ +package com.akash.logical; + +import java.io.FileNotFoundException; + +public class A { + + public void m1() throws FileNotFoundException{ + System.out.println("FROM A"); + } + +} diff --git a/OppsConcepts/src/com/akash/logical/B.java b/OppsConcepts/src/com/akash/logical/B.java new file mode 100644 index 0000000..1846520 --- /dev/null +++ b/OppsConcepts/src/com/akash/logical/B.java @@ -0,0 +1,11 @@ +package com.akash.logical; + +import java.io.FileNotFoundException; + +public class B extends A{ + + public void m1() throws FileNotFoundException{ + System.out.println("FROM B"); + } + +} diff --git a/OppsConcepts/src/com/akash/logical/Demo.java b/OppsConcepts/src/com/akash/logical/Demo.java new file mode 100644 index 0000000..40b7d4b --- /dev/null +++ b/OppsConcepts/src/com/akash/logical/Demo.java @@ -0,0 +1,24 @@ +package com.akash.logical; + +import java.util.ArrayList; +import java.util.List; + +public class Demo { + + /*Which of these method is used to find out that a thread is still running or not?*/ + + public static void main(String[] args) { + + int x[] = {120, 100, 010}; + + for(int i = 0; i list = new ArrayList<>(); + list.add("Akash"); + list.add("Kumar"); + + System.out.println(list); + } + +} diff --git a/OppsConcepts/src/com/akash/logical/DemoProgram.java b/OppsConcepts/src/com/akash/logical/DemoProgram.java new file mode 100644 index 0000000..f45189a --- /dev/null +++ b/OppsConcepts/src/com/akash/logical/DemoProgram.java @@ -0,0 +1,12 @@ +package com.akash.logical; + +public class DemoProgram { + + public static void main(String[] args) { + + System.out.println(10+20+"JAVA"); + System.out.println("-------------"); + System.out.println("Java"+10+20); + } + +} diff --git a/OppsConcepts/src/com/akash/logical/List.java b/OppsConcepts/src/com/akash/logical/List.java new file mode 100644 index 0000000..f612598 --- /dev/null +++ b/OppsConcepts/src/com/akash/logical/List.java @@ -0,0 +1,12 @@ +package com.akash.logical; + +import java.util.Arrays; + +public class List { + public static void main(String args) { + + } + List list = (List) Arrays.asList(1,2); + //List a = lsit; + +} diff --git a/OppsConcepts/src/com/akash/methodOverloadingE/AddResult.java b/OppsConcepts/src/com/akash/methodOverloadingE/AddResult.java new file mode 100644 index 0000000..ccaa4dc --- /dev/null +++ b/OppsConcepts/src/com/akash/methodOverloadingE/AddResult.java @@ -0,0 +1,26 @@ +package com.akash.methodOverloadingE; + +public class AddResult { + + // its example of Method Overloading + + public AddResult() { + + } + + public int add(int a, int b) { + return a+b; + } + +// public int add(int a, int b) { // it not possible bcz its same method and parameter. its ambuigity issues +// +// return a+b; +// } + + public double add(double a, double b) { // its be different method name is same but different argument + + return a-b; + } + + +} diff --git a/OppsConcepts/src/com/akash/methodOverloadingE/Runner.java b/OppsConcepts/src/com/akash/methodOverloadingE/Runner.java new file mode 100644 index 0000000..480e519 --- /dev/null +++ b/OppsConcepts/src/com/akash/methodOverloadingE/Runner.java @@ -0,0 +1,15 @@ +package com.akash.methodOverloadingE; + +public class Runner { + + public static void main(String[] args) { + AddResult addResult = new AddResult(); + + System.out.println(addResult.add(25.3, 19.5)); + System.out.println(addResult.add(26, 25)); + + + + } + +} diff --git a/OppsConcepts/src/com/akash/overridingMethodExam/Base.java b/OppsConcepts/src/com/akash/overridingMethodExam/Base.java new file mode 100644 index 0000000..33488e1 --- /dev/null +++ b/OppsConcepts/src/com/akash/overridingMethodExam/Base.java @@ -0,0 +1,17 @@ +package com.akash.overridingMethodExam; + +public class Base { + + public static void get() { + System.out.println("Base HEllo"); + } + + public static void display() { + System.out.println("Base Static or class method from base"); + } + + public void print() { + System.out.println("Base Non-static or instance method from base"); + } + +} diff --git a/OppsConcepts/src/com/akash/overridingMethodExam/Derived.java b/OppsConcepts/src/com/akash/overridingMethodExam/Derived.java new file mode 100644 index 0000000..3acc412 --- /dev/null +++ b/OppsConcepts/src/com/akash/overridingMethodExam/Derived.java @@ -0,0 +1,12 @@ +package com.akash.overridingMethodExam; + +public class Derived extends Base{ + + public static void get() { + System.out.println("Derived HEllo"); + } + public void print() { + System.out.println(" Derived Its print method..Non static or instance method from Derived.."); + } + +} diff --git a/OppsConcepts/src/com/akash/overridingMethodExam/Runner.java b/OppsConcepts/src/com/akash/overridingMethodExam/Runner.java new file mode 100644 index 0000000..cf4dbc4 --- /dev/null +++ b/OppsConcepts/src/com/akash/overridingMethodExam/Runner.java @@ -0,0 +1,14 @@ +package com.akash.overridingMethodExam; + +public class Runner { + + public static void main(String[] args) { + + Base base = new Derived(); + base.print(); /*Derived*/ + + Derived.get(); + + } + +} diff --git a/OppsConcepts/src/com/akash/runtimepolymorphism/Audi.java b/OppsConcepts/src/com/akash/runtimepolymorphism/Audi.java new file mode 100644 index 0000000..d37ec5f --- /dev/null +++ b/OppsConcepts/src/com/akash/runtimepolymorphism/Audi.java @@ -0,0 +1,8 @@ +package com.akash.runtimepolymorphism; + +public class Audi extends Car{ + void run() { + System.out.println("Audi is running with 400 Km "); + } + +} diff --git a/OppsConcepts/src/com/akash/runtimepolymorphism/Car.java b/OppsConcepts/src/com/akash/runtimepolymorphism/Car.java new file mode 100644 index 0000000..0f14233 --- /dev/null +++ b/OppsConcepts/src/com/akash/runtimepolymorphism/Car.java @@ -0,0 +1,8 @@ +package com.akash.runtimepolymorphism; + +public class Car { + void run() { + System.out.println("Car is running"); + } + +} diff --git a/OppsConcepts/src/com/akash/runtimepolymorphism/Runner.java b/OppsConcepts/src/com/akash/runtimepolymorphism/Runner.java new file mode 100644 index 0000000..3910cc0 --- /dev/null +++ b/OppsConcepts/src/com/akash/runtimepolymorphism/Runner.java @@ -0,0 +1,11 @@ +package com.akash.runtimepolymorphism; + +public class Runner { + + public static void main(String[] args) { + + Car car = new Audi(); + car.run(); /*Audi*/ + } + +} diff --git a/OppsConcepts/src/com/akash/staticblock/MultipleStaticBlockdemo.java b/OppsConcepts/src/com/akash/staticblock/MultipleStaticBlockdemo.java new file mode 100644 index 0000000..79e39b5 --- /dev/null +++ b/OppsConcepts/src/com/akash/staticblock/MultipleStaticBlockdemo.java @@ -0,0 +1,26 @@ +package com.akash.staticblock; + +public class MultipleStaticBlockdemo { + + static int num; + static String str; + + static { + System.out.println("static block 1"); // 1st execute + num = 68; + str= "Block1"; + } + static { + System.out.println("Static block 2"); // 2nd execute + num = 70; + str = "Block2"; + } + public static void main(String[] args) { + // TODO + System.out.println("value of num: "+ num); // 3rd execute in second block2 + System.out.println("value of str: "+ str); // 4th block in second block2 + + + } + +} diff --git a/OppsConcepts/src/com/akash/staticblock/StaticBlockVariable.java b/OppsConcepts/src/com/akash/staticblock/StaticBlockVariable.java new file mode 100644 index 0000000..ff6d856 --- /dev/null +++ b/OppsConcepts/src/com/akash/staticblock/StaticBlockVariable.java @@ -0,0 +1,33 @@ +package com.akash.staticblock; + +public class StaticBlockVariable { + + static int var1= 54; + String var2; + + public static void main(String[] args) { + // TODO + StaticBlockVariable staticBlockVariable = new StaticBlockVariable(); + StaticBlockVariable staticBlockVariable2 = new StaticBlockVariable(); + + staticBlockVariable.var1=10; // 20 + staticBlockVariable.var2="Hello 1st"; // same + + + staticBlockVariable2.var1= 30; // 20 + staticBlockVariable2.var2="Hello 2nd"; // same + + var1=62; + + /*This will overwrite the value of var1 because var1 has a single + * copy shared among both the objects */ + + System.out.println("obj 1 int : "+ staticBlockVariable.var1); + System.out.println("obj 1 string : "+ staticBlockVariable.var2); + System.out.println("obj 2 int : "+ staticBlockVariable2.var1); + System.out.println("obj 2 String : "+ staticBlockVariable2.var2); + System.out.println("obj 2 Intance : "+ var1); + + } + +} \ No newline at end of file diff --git a/OppsConcepts/src/com/akash/staticblock/StaticVariable.java b/OppsConcepts/src/com/akash/staticblock/StaticVariable.java new file mode 100644 index 0000000..4eff92b --- /dev/null +++ b/OppsConcepts/src/com/akash/staticblock/StaticVariable.java @@ -0,0 +1,22 @@ +package com.akash.staticblock; + +public class StaticVariable { + + int var1; + static int var3; + static String var2; + public static void main(String[] args) { + // TODO + disp(); + + } + + public static void disp() { + // TODO + System.out.println("var1 is "+ new StaticVariable().var1); // 0 + System.out.println("var1 is "+ var2); // null + System.out.println("var1 is "+ var3); // 0 + + } + +} diff --git a/OppsConcepts/src/com/akash/staticblock/TestDemo.java b/OppsConcepts/src/com/akash/staticblock/TestDemo.java new file mode 100644 index 0000000..6195778 --- /dev/null +++ b/OppsConcepts/src/com/akash/staticblock/TestDemo.java @@ -0,0 +1,6 @@ +package com.akash.staticblock; + +public interface TestDemo { + static int i=6; + +} diff --git a/OppsConcepts/src/com/akash/stringImmutable/StringClassImmutableHashCode.java b/OppsConcepts/src/com/akash/stringImmutable/StringClassImmutableHashCode.java new file mode 100644 index 0000000..5f68708 --- /dev/null +++ b/OppsConcepts/src/com/akash/stringImmutable/StringClassImmutableHashCode.java @@ -0,0 +1,20 @@ +package com.akash.stringImmutable; + +public class StringClassImmutableHashCode { + + public static void main(String[] args) { + // TODO + String str = "Akki"; + str="kumar"; + String s = new String("Akki"); + String s2 = s; + System.out.println(s2); + + System.out.println(str); + str.hashCode(); + str.hashCode(); + System.out.println(str); + + } + +} diff --git a/OppsConcepts/src/com/akash/stringdemo/Child.java b/OppsConcepts/src/com/akash/stringdemo/Child.java new file mode 100644 index 0000000..f120cde --- /dev/null +++ b/OppsConcepts/src/com/akash/stringdemo/Child.java @@ -0,0 +1,9 @@ +package com.akash.stringdemo; + +public class Child extends Parent { + + @Override void show(){ + System.out.println("Child class sooon"); + } + +} diff --git a/OppsConcepts/src/com/akash/stringdemo/ConctTest.java b/OppsConcepts/src/com/akash/stringdemo/ConctTest.java new file mode 100644 index 0000000..55068be --- /dev/null +++ b/OppsConcepts/src/com/akash/stringdemo/ConctTest.java @@ -0,0 +1,21 @@ +package com.akash.stringdemo; + +public class ConctTest { + + public static void main(String[] args) { + + String str = "hello"; + + String s = new String("Akash"); + String s2= s.concat(" kumar"); + System.out.println(s2); + + String str1=str.concat(" I am"); + System.out.println(str1); + + str = str.concat(" I am not for you"); + System.out.println(str); + + } + +} diff --git a/OppsConcepts/src/com/akash/stringdemo/ExceptionTest.java b/OppsConcepts/src/com/akash/stringdemo/ExceptionTest.java new file mode 100644 index 0000000..baf36de --- /dev/null +++ b/OppsConcepts/src/com/akash/stringdemo/ExceptionTest.java @@ -0,0 +1,19 @@ +package com.akash.stringdemo; + +public class ExceptionTest { + + public static void main(String[] args) { + try { + System.out.println("**********Start ********"); + System.exit(0); + System.out.println("********Middle***********"); + }catch(SecurityException e) { + System.out.println(e.getMessage()+" Security Exception"); + }catch(Exception e) { + System.out.println(e.getMessage()+ " Exception"); + }finally { + System.out.println("*************End************"); + } + } + +} diff --git a/OppsConcepts/src/com/akash/stringdemo/MainClassPC.java b/OppsConcepts/src/com/akash/stringdemo/MainClassPC.java new file mode 100644 index 0000000..3a77a42 --- /dev/null +++ b/OppsConcepts/src/com/akash/stringdemo/MainClassPC.java @@ -0,0 +1,10 @@ +package com.akash.stringdemo; + +public class MainClassPC { + + public static void main(String[] args) { + Child parent =(Child) new Parent(); + parent.show(); + } + +} diff --git a/OppsConcepts/src/com/akash/stringdemo/Parent.java b/OppsConcepts/src/com/akash/stringdemo/Parent.java new file mode 100644 index 0000000..d2f9597 --- /dev/null +++ b/OppsConcepts/src/com/akash/stringdemo/Parent.java @@ -0,0 +1,9 @@ +package com.akash.stringdemo; + +public class Parent { + + void show() { + System.out.println("parent class is soon ..... "); + } + +} diff --git a/Program/src/com/akash/convertdata/Abc.java b/Program/src/com/akash/convertdata/Abc.java new file mode 100644 index 0000000..f9b42ab --- /dev/null +++ b/Program/src/com/akash/convertdata/Abc.java @@ -0,0 +1,31 @@ +package com.akash.convertdata; + +import java.util.Scanner; + +public class Abc { + + public static void main(String[] args) { + + Scanner scanner = new Scanner(System.in); +// System.out.println("Enter the number"); +// double num = scanner.nextDouble(); +// +// int n = (int) num; +// System.out.println(n); + + String search = "loop"; + String [] word = {"kool","Hero", "loop"}; + + for(int i=0;i last) { + System.out.println("Is Not found"); + } + } +} \ No newline at end of file diff --git a/Program/src/com/akash/program/CheckDigitOnly.java b/Program/src/com/akash/program/CheckDigitOnly.java new file mode 100644 index 0000000..7e5af56 --- /dev/null +++ b/Program/src/com/akash/program/CheckDigitOnly.java @@ -0,0 +1,26 @@ +package com.akash.program; + +public class CheckDigitOnly { + + public static void main(String[] args) { + + String str = "2222"; + int length = str.length(); + + System.out.println(onlyDigitValue(length, str)); + + } + + private static boolean onlyDigitValue(int length, String str) { + // TODO Auto-generated method stub + + for(int i = 0; i hashmap = new HashMap<>(); + + for(int i = 0; i entry: hashmap.entrySet()) { + System.out.println(entry.getKey()+ " Count no : "+ entry.getValue()); + } + } + +} diff --git a/Program/src/com/akash/program/FirstSecondLargestNumInAnArray.java b/Program/src/com/akash/program/FirstSecondLargestNumInAnArray.java new file mode 100644 index 0000000..b59bf76 --- /dev/null +++ b/Program/src/com/akash/program/FirstSecondLargestNumInAnArray.java @@ -0,0 +1,5 @@ +package com.akash.program; + +public class FirstSecondLargestNumInAnArray { + +} diff --git a/Program/src/com/akash/program/NoDuplicationProgram.java b/Program/src/com/akash/program/NoDuplicationProgram.java new file mode 100644 index 0000000..4e37bbc --- /dev/null +++ b/Program/src/com/akash/program/NoDuplicationProgram.java @@ -0,0 +1,38 @@ +package com.akash.program; + +public class NoDuplicationProgram { + + public static void main(String[] args) { + + int arr[] = {1, 5,6,2,6, 8, 1, 3, 4, 2}; + + printElementWithNoDuplicate(arr, arr.length); + + } + + private static void printElementWithNoDuplicate(int[] arr, int length) { + + boolean flag [] = new boolean[length]; + int count; + int x= 0; + for(int i = 0; i0) { + remainder = n % 10; + sum = (sum*10)+remainder; + } + if(temp == sum) { + System.out.println("is Palidrome number : "+ sum); + }else { + System.out.println("is not Palidrome number : "+ sum); + } + Collections.sort(new ArrayList()); + System.out.println("Hello - - - - - - -- - - - - "); + } +} \ No newline at end of file diff --git a/Program/src/com/akash/program/ReverseArray.java b/Program/src/com/akash/program/ReverseArray.java new file mode 100644 index 0000000..6aff32c --- /dev/null +++ b/Program/src/com/akash/program/ReverseArray.java @@ -0,0 +1,36 @@ +package com.akash.program; + +import java.util.Arrays; +import java.util.Collections; + +public class ReverseArray { + + public static void main(String[] args) { + + Integer[] intArray = {10,20,30,40,50,60,70,80,90}; + + for(int i =0; i=0; i--) { + System.out.print(intArray[i]+" "); + } + System.out.println(" "); + System.out.println("Using Collections"); + + Collections.reverse(Arrays.asList(intArray)); + System.out.println("Reverse Number"); + System.out.print(Arrays.asList(intArray)); + System.out.println(" "); + + } + +} diff --git a/Program/src/com/akash/program/Runner.java b/Program/src/com/akash/program/Runner.java new file mode 100644 index 0000000..9bf153c --- /dev/null +++ b/Program/src/com/akash/program/Runner.java @@ -0,0 +1,16 @@ +package com.akash.program; + + + +public class Runner { + + public static void main(String[] args) { + + /* List list = Arrays.asList(1,2); + List l = list; + l.add(3.14);*/ + + System.out.println(2); + } + +} diff --git a/Program/src/com/akash/programming/ArmstrongNumber.java b/Program/src/com/akash/programming/ArmstrongNumber.java new file mode 100644 index 0000000..dab8019 --- /dev/null +++ b/Program/src/com/akash/programming/ArmstrongNumber.java @@ -0,0 +1,28 @@ +package com.akash.programming; + +public class ArmstrongNumber { + + public static void main(String[] args) { + + int sum = 0, r, temp; + + int n = 153; + + temp = n; + + while(n>0) { + + r = n%10; + sum = sum+ (r*r*r); + n = n/10; + } + + if(temp == sum) { + System.out.println("That is ArmStrong Number"); + }else { + System.out.println("That is not ArmStrong Number"); + } + + } + +} diff --git a/Program/src/com/akash/programming/CloneExample.java b/Program/src/com/akash/programming/CloneExample.java new file mode 100644 index 0000000..f2a17f8 --- /dev/null +++ b/Program/src/com/akash/programming/CloneExample.java @@ -0,0 +1,27 @@ +package com.akash.programming; + +public class CloneExample implements Cloneable{ + + String sal; + String size; + String company; + + public static void main(String[] args) { + CloneExample clone = new CloneExample(); + clone.sal = "7000000"; + clone.size = "10000"; + clone.company = "Sapient"; + + try { + CloneExample cloneExample = (CloneExample) clone.clone(); + + System.out.println(cloneExample.sal); + System.out.println(cloneExample.size); + System.out.println(cloneExample.company); + + } catch (CloneNotSupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/Program/src/com/akash/programming/ContainsOnlyLetters.java b/Program/src/com/akash/programming/ContainsOnlyLetters.java new file mode 100644 index 0000000..81aebf7 --- /dev/null +++ b/Program/src/com/akash/programming/ContainsOnlyLetters.java @@ -0,0 +1,29 @@ +package com.akash.programming; + +public class ContainsOnlyLetters { + + public static void main(String[] args) { + + String str = "HelloIam"; + int length = str.length(); + + System.out.println(isFindOnlyLetters(str, length)); + } + + private static boolean isFindOnlyLetters(String str, int length) { + // TODO Auto-generated method stub + + if(str == null || str == "") + return false; + + /*Traverse the String*/ + + for(int i = 0; i< length; i++) { + + if(!Character.isLetter(str.charAt(i))){ + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/Program/src/com/akash/programming/CountFrequency.java b/Program/src/com/akash/programming/CountFrequency.java new file mode 100644 index 0000000..98eadee --- /dev/null +++ b/Program/src/com/akash/programming/CountFrequency.java @@ -0,0 +1,28 @@ +package com.akash.programming; + +public class CountFrequency { + + public static void main(String[] args) { + + int count; + + String str ="Akash"; + int length = str.length(); + + for(char c = 'A'; c<='z'; c++ ) { + count = 0; + for(int i = 0; i0) { + System.out.println("The character "+ c+ " of count "+ count); + } + } + + } + +} diff --git a/Program/src/com/akash/programming/Factorial.java b/Program/src/com/akash/programming/Factorial.java new file mode 100644 index 0000000..55e285b --- /dev/null +++ b/Program/src/com/akash/programming/Factorial.java @@ -0,0 +1,21 @@ +package com.akash.programming; + +public class Factorial { + + /*Complexity : O (1)*/ + + public static void main(String[] args) { + int n = 5; + int finalValue = factorialNumber(n); + System.out.println("Factorial of " + n +" is "+ finalValue ); + } + + private static int factorialNumber(int n) { + // TODO Auto-generated method stub + int fact = 1; + for(int i = 1; i <=n; i++) { + fact = fact * i; + } + return fact; + } +} \ No newline at end of file diff --git a/Program/src/com/akash/programming/FibonanciSeries.java b/Program/src/com/akash/programming/FibonanciSeries.java new file mode 100644 index 0000000..56bdf54 --- /dev/null +++ b/Program/src/com/akash/programming/FibonanciSeries.java @@ -0,0 +1,16 @@ +package com.akash.programming; + +public class FibonanciSeries { + + public static void main(String[] args) { + + int n1 = 0, n2=1, n3, count = 10; + System.out.print(n1+","+n2); + for(int i = 2; i map = new HashMap<>(); + + for(int i = 0; i mapEntry : map.entrySet()) { + System.out.println("Duplicate Word "+mapEntry.getKey()+ " it value "+mapEntry.getValue()); + } + } +} \ No newline at end of file diff --git a/Program/src/com/akash/programming/FindLargeNumber.java b/Program/src/com/akash/programming/FindLargeNumber.java new file mode 100644 index 0000000..7e30703 --- /dev/null +++ b/Program/src/com/akash/programming/FindLargeNumber.java @@ -0,0 +1,26 @@ +package com.akash.programming; + +public class FindLargeNumber { + + static int arr[] = {5,7,90, 45, 3}; + + private static int findLargest(){ + int max = arr[0]; + + + for(int i = 1; i max) { + max = arr[i]; + } + } + + return max; + } + public static void main(String[] args) { + + System.out.println("Find largest number : "+ findLargest()); + + } + + +} diff --git a/Program/src/com/akash/programming/FindSecondLargest.java b/Program/src/com/akash/programming/FindSecondLargest.java new file mode 100644 index 0000000..aa41ed5 --- /dev/null +++ b/Program/src/com/akash/programming/FindSecondLargest.java @@ -0,0 +1,34 @@ +package com.akash.programming; + +public class FindSecondLargest { + + public static void main(String[] args) { + + int str [] = {25, 14, 63, 95, 12, 3, 48}; + + int length = str.length; + + int secondhighest = findSecondLarge(str, length); + + System.out.println("second highest number "+ secondhighest); + } + + private static int findSecondLarge(int[] arr, int length) { + + int temp; + + for(int i = 0; i arr[j]) { + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + + System.out.println(arr[0]); + return arr[length-2]; + } + +} diff --git a/Program/src/com/akash/programming/FindUniqueElement.java b/Program/src/com/akash/programming/FindUniqueElement.java new file mode 100644 index 0000000..cfd08cd --- /dev/null +++ b/Program/src/com/akash/programming/FindUniqueElement.java @@ -0,0 +1,29 @@ +package com.akash.programming; + +import java.util.ArrayList; +import java.util.List; + +public class FindUniqueElement { + + public static void main(String[] args) { + int arr1[] = new int[] {1, 2, 3, 5, 6 ,8}; + int arr2[] = new int[] {5, 6, 7, 8}; + + boolean contains = false; + + List list = new ArrayList(); + for(int i = 0; i list = new LinkedList<>(); + + list.add("Akash"); + list.add("Ravi"); + list.add("Hero"); + list.add("A++"); + list.add("company"); + + System.out.println(list); + + Iterator iterator = list.iterator(); + + while(iterator.hasNext()) { + String value = iterator.next(); + System.out.println("--------------"); + + if(value.contains("A++")) { + System.out.println("Available"); + }else if(value.contains("company")){ + System.out.println("Available"); + }else if (value.contains("Jai")) { + System.out.println("Not Available"); + } + } + } + +} diff --git a/Program/src/com/akash/programming/MaxDifference.java b/Program/src/com/akash/programming/MaxDifference.java new file mode 100644 index 0000000..72b15e2 --- /dev/null +++ b/Program/src/com/akash/programming/MaxDifference.java @@ -0,0 +1,31 @@ +package com.akash.programming; + +public class MaxDifference { + + public static void main(String[] args) { + + int arr[] = {4, 6, 7, 6, 12, 45, 75, 23}; + + System.out.println("Size :: "+ arr.length); + int result = maxDifference(arr, arr.length); + + System.out.println("Final Max Differece :: "+result); + + } + + static int maxDifference(int arr[], int arraySize) { + + int max = arr[1]- arr[0]; + int i, j; + + for(i= 0; i max) { + max = arr[j]-arr[i]; + } + } + } + return max; + } +} \ No newline at end of file diff --git a/Program/src/com/akash/programming/PalidromeNumber.java b/Program/src/com/akash/programming/PalidromeNumber.java new file mode 100644 index 0000000..b4a81b9 --- /dev/null +++ b/Program/src/com/akash/programming/PalidromeNumber.java @@ -0,0 +1,25 @@ +package com.akash.programming; + +public class PalidromeNumber { + + /*Example : 454 = 454 that reverse number*/ + /*% :: Modulus*/ + + public static void main(String[] args) { + + int r, sum = 0; + int n = 454; + + int temp = n; + while(n>0) { + r = n%10; + sum = (sum*10)+r; + n = n/10; + } + + if(temp == sum) + System.out.println("Is Palidrome Number"); + else + System.out.println("Not Palidrome Number"); + } +} diff --git a/Program/src/com/akash/programming/PrimeNumber.java b/Program/src/com/akash/programming/PrimeNumber.java new file mode 100644 index 0000000..7edd0c8 --- /dev/null +++ b/Program/src/com/akash/programming/PrimeNumber.java @@ -0,0 +1,23 @@ +package com.akash.programming; + +public class PrimeNumber { + + public static void main(String[] args) { + if(isPrimeNumber(29)) { + System.out.println("Is prime number "); + }else { + System.out.println("Is not prime number"); + } + } + + static boolean isPrimeNumber(int n) { + + for(int i = 2; i>> "); + System.out.println(ch); + + System.out.println("Two numer"); + System.out.println(ch1); + } + + private static void replaceTwoNumber(char[] ch1, int length) { + + for(int i = 1; i list = new ArrayList(); + for (int i = 0; i < arr1.length; i++) { + for (int j = 0; j < arr2.length; j++) { + if (arr1[i] == arr2[j]) { + contains = true; + break; + } + } + + if(!contains){ + list.add(arr1[i]); + } + + else{ + contains = false; + } + } + System.out.println(list); + } + +} diff --git a/designPattern/.classpath b/designPattern/.classpath new file mode 100644 index 0000000..e461bea --- /dev/null +++ b/designPattern/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/designPattern/.project b/designPattern/.project new file mode 100644 index 0000000..ab23490 --- /dev/null +++ b/designPattern/.project @@ -0,0 +1,17 @@ + + + DesignPattern + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/designPattern/.settings/org.eclipse.jdt.core.prefs b/designPattern/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/designPattern/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/designPattern/Singleton.java b/designPattern/Singleton.java new file mode 100644 index 0000000..c661acf --- /dev/null +++ b/designPattern/Singleton.java @@ -0,0 +1,18 @@ +package com.akash.designPattern; + +public class Singleton { + + private static Singleton singleton = null; + //private static Singleton singleton = null; + + private Singleton() { + // constructor + } + + public static Singleton getInstance() { + if(singleton == null) { + singleton = new Singleton(); + } + return singleton; + } +} \ No newline at end of file diff --git a/designPattern/SingletonDemo.java b/designPattern/SingletonDemo.java new file mode 100644 index 0000000..7e3ec5d --- /dev/null +++ b/designPattern/SingletonDemo.java @@ -0,0 +1,18 @@ +package com.akash.designPattern; + +public class SingletonDemo { + + private static SingletonDemo singleton = null; + + private SingletonDemo() { + // TODO + } + + public static SingletonDemo getInstance() { + if(singleton == null) { + singleton = new SingletonDemo(); + } + return singleton; + } + +} diff --git a/designPattern/src/com/akash/designPattern/Singleton.java b/designPattern/src/com/akash/designPattern/Singleton.java new file mode 100644 index 0000000..c661acf --- /dev/null +++ b/designPattern/src/com/akash/designPattern/Singleton.java @@ -0,0 +1,18 @@ +package com.akash.designPattern; + +public class Singleton { + + private static Singleton singleton = null; + //private static Singleton singleton = null; + + private Singleton() { + // constructor + } + + public static Singleton getInstance() { + if(singleton == null) { + singleton = new Singleton(); + } + return singleton; + } +} \ No newline at end of file diff --git a/designPattern/src/com/akash/designPattern/SingletonDemo.java b/designPattern/src/com/akash/designPattern/SingletonDemo.java new file mode 100644 index 0000000..7e3ec5d --- /dev/null +++ b/designPattern/src/com/akash/designPattern/SingletonDemo.java @@ -0,0 +1,18 @@ +package com.akash.designPattern; + +public class SingletonDemo { + + private static SingletonDemo singleton = null; + + private SingletonDemo() { + // TODO + } + + public static SingletonDemo getInstance() { + if(singleton == null) { + singleton = new SingletonDemo(); + } + return singleton; + } + +} diff --git a/Java8Program/src/com/akash/factorypattern/Android.java b/designPattern/src/com/akash/factorypattern/Android.java similarity index 100% rename from Java8Program/src/com/akash/factorypattern/Android.java rename to designPattern/src/com/akash/factorypattern/Android.java diff --git a/Java8Program/src/com/akash/factorypattern/IOS.java b/designPattern/src/com/akash/factorypattern/IOS.java similarity index 100% rename from Java8Program/src/com/akash/factorypattern/IOS.java rename to designPattern/src/com/akash/factorypattern/IOS.java diff --git a/Java8Program/src/com/akash/factorypattern/OS.java b/designPattern/src/com/akash/factorypattern/OS.java similarity index 100% rename from Java8Program/src/com/akash/factorypattern/OS.java rename to designPattern/src/com/akash/factorypattern/OS.java diff --git a/Java8Program/src/com/akash/factorypattern/OperatingSystemFactory.java b/designPattern/src/com/akash/factorypattern/OperatingSystemFactory.java similarity index 100% rename from Java8Program/src/com/akash/factorypattern/OperatingSystemFactory.java rename to designPattern/src/com/akash/factorypattern/OperatingSystemFactory.java diff --git a/Java8Program/src/com/akash/factorypattern/RunnerFactoryDesign.java b/designPattern/src/com/akash/factorypattern/RunnerFactoryDesign.java similarity index 100% rename from Java8Program/src/com/akash/factorypattern/RunnerFactoryDesign.java rename to designPattern/src/com/akash/factorypattern/RunnerFactoryDesign.java diff --git a/Java8Program/src/com/akash/factorypattern/Window.java b/designPattern/src/com/akash/factorypattern/Window.java similarity index 100% rename from Java8Program/src/com/akash/factorypattern/Window.java rename to designPattern/src/com/akash/factorypattern/Window.java diff --git a/designPattern/src/com/akash/singleton/RunnerClass.java b/designPattern/src/com/akash/singleton/RunnerClass.java new file mode 100644 index 0000000..43f353b --- /dev/null +++ b/designPattern/src/com/akash/singleton/RunnerClass.java @@ -0,0 +1,11 @@ +package com.akash.singleton; + +public class RunnerClass { + + public static void main(String[] args) { + + SingletonApp singletonApp = SingletonApp.getInstance(); + System.out.println(singletonApp); + } + +} diff --git a/designPattern/src/com/akash/singleton/SingletonApp.java b/designPattern/src/com/akash/singleton/SingletonApp.java new file mode 100644 index 0000000..e0fcc4f --- /dev/null +++ b/designPattern/src/com/akash/singleton/SingletonApp.java @@ -0,0 +1,21 @@ +package com.akash.singleton; + +public class SingletonApp { + + private static SingletonApp singletonApp = null; + + private SingletonApp() {} + + + public static SingletonApp getInstance() { + + if(singletonApp == null) { + singletonApp = new SingletonApp(); + } + + return singletonApp; + } + + + +}