Skip to content

Commit

Permalink
Programming Java Concept
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAkashKumar committed Oct 11, 2020
1 parent 0a33ca2 commit 11b0793
Show file tree
Hide file tree
Showing 264 changed files with 4,663 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.akash.collectionExample;

import java.util.concurrent.ConcurrentSkipListMap;

public class ConcurrentSkipListDemo {

public static void main(String[] args) {
ConcurrentSkipListMap<String, Integer> map = new ConcurrentSkipListMap<>();
ConcurrentSkipListMap<Integer, String> 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);
}

}
Original file line number Diff line number Diff line change
@@ -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);


}

}
Original file line number Diff line number Diff line change
@@ -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<String, Integer> hash = new HashMap<>();
hash.put("Akash", 5);
hash.put("Akki", 7);
Collections.synchronizedList(new ArrayList<String>());
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());


}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.akash.collectionExample;

import java.util.LinkedList;

public class LinkListDemo {

public static void main(String[] args) {

LinkedList<String> list = new LinkedList<String>();

list.add("Akash");
list.add("RAVI");
list.add("Rahul");
list.add("Aditya");

System.out.println(list);
System.out.println(list.getFirst());

}

}
38 changes: 38 additions & 0 deletions CollectionProgram/src/com/akash/collectionss/ComparaterTest.java
Original file line number Diff line number Diff line change
@@ -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<String> arrayList = new ArrayList<String>();

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<String> 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");


}

}
14 changes: 14 additions & 0 deletions CollectionProgram/src/com/akash/collectionss/StringSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.akash.collectionss;

import java.util.Comparator;

public class StringSort implements Comparator<String> {


@Override
public int compare(String arg1, String arg2) {

return arg1.charAt(1)-arg2.charAt(1);
}

}
Original file line number Diff line number Diff line change
@@ -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<String> arrayList = new CopyOnWriteArrayList<>();
arrayList.add("Akash");
arrayList.add("Abhinav");
arrayList.add("Akki");
arrayList.add("Priya");
arrayList.add("sonam");

new Thread() {
public void run() {
Iterator<String> 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();
}
}
25 changes: 25 additions & 0 deletions CollectionProgram/src/com/akash/swaping/SwapingwithoutThird.java
Original file line number Diff line number Diff line change
@@ -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();
}

}
21 changes: 21 additions & 0 deletions CollectionProgram/src/com/akash/swaping/SwappingString.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
6 changes: 6 additions & 0 deletions DataStructure/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions DataStructure/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DataStructure</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions DataStructure/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions DataStructure/src/com/akash/binarySearch/BinaryRecursion.java
Original file line number Diff line number Diff line change
@@ -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; i<number; i++) {
array[i] = scanner.nextInt();
}
System.out.println("Enter value to find ");
search = scanner.nextInt();



scanner.close();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.akash.binaryTreeRecursion;

public class BinaryTreeUsingRecursion {

public static void main(String[] args) {
// TODO
class TreeNode{
String data;
TreeNode left, right;

TreeNode(String value){
this.data = value;
left = right = null;
}
boolean isLeaf() {
return left == null?right == null: false;
}
}
TreeNode root;
}
}
47 changes: 47 additions & 0 deletions DataStructure/src/com/akash/circularLinked/CreateCircularList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.akash.circularLinked;

public class CreateCircularList {
static Node head= null;
static Node tail= null;
public class Node{
int data;
Node next;
Node(int d){
data = d;
}
}
public void add(int data) {
Node node = new Node(data);
if(head == null) {
head = node;
tail = node;
node.next = head;
}else {
tail.next = node;
tail = node;
tail.next = head;
}
}
void display() {
Node current = head;
if(head == null) {
System.out.println("List is empty....");
}else {
System.out.println("Nodes of the circular linked list");
do {
System.out.println("Node of the circular linked list");
System.out.println(""+current.data);
current = current.next;
}while(current !=head);
System.out.println();
}
}
public static void main(String[] args) {
// TODOO
CreateCircularList circle = new CreateCircularList();
circle.add(2);
circle.add(5);
circle.add(8);
circle.display();
}
}
Loading

0 comments on commit 11b0793

Please sign in to comment.