Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 5 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target/
*.iml
*.class
out/
.idea/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Main
class Test
{
public static void main(String[] args) {
int i,j,k=0;
Expand All @@ -13,4 +13,4 @@ public static void main(String[] args) {
}
System.out.println(k);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Multiple statements can be there for single try

class Main
class Test
{
public static void main(String[] args) {
int i,j,k=0;
Expand All @@ -26,4 +26,4 @@ public static void main(String[] args) {
}
System.out.println(k);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import java.io.*;

class Main
class Test
{
public static void main(String[] args) {
int i,j=1,k=0;
Expand All @@ -27,4 +27,4 @@ public static void main(String[] args) {
}
System.out.println(k);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.io.*;

class Main
class Test
{
public static void main(String[] args) {
int i,j=1,k=0;
Expand Down Expand Up @@ -30,4 +30,4 @@ public static void main(String[] args) {
}
System.out.println(k);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* <li>By storing the current object in a file and then reading it back</li>
* </ul>
*/
public class Main {
public class Test {
public static void main(String[] args) throws CloneNotSupportedException {
A obj1 = new A();
obj1.i = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../12.1 - File Handling Example">
<sourceFolder url="file://$MODULE_DIR$/../12.1 - File Handling Example/src" isTestSource="false" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
public class Test {
private static final File FILE = new File("12 - File Handling + Serializable/12.1 - File Handling Example/src/demo.txt");

public static void main(String[] args) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* {@code Properties} file: is used to store configuration
*/

public class Main {
public class Test {

private static final File PROPERTIES_FILE = new File("12 - File Handling + Serializable/12.2 - Properties file/src/config.properties");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class Main {
public class Test {

private static final File FILE = new File("12 - File Handling + Serializable/12.3 - Object Serialization/src/obj.txt");

Expand All @@ -36,4 +36,4 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio

class Save implements Serializable {
int i;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*</p>
*/

public class Main {
public class Test {
private static final File XML_FILE = new File("12 - File Handling + Serializable/12.4 - Serialization using XMLEncoder/src/obj.txt");

public static void main(String[] args) throws FileNotFoundException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.io.Serializable;
import java.util.List;

public class Main {
public class Test {
private static final File XML_FILE = new File("12 - File Handling + Serializable/12.4 - Serialization using XMLEncoder/src/obj.txt");

public static void main(String[] args) throws FileNotFoundException {
Expand Down Expand Up @@ -66,4 +66,4 @@ public void setSname(String sname) {
public String toString() {
return "Student{" + "rollNo=" + rollNo + ", sname=" + sname + '}';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
* Normally used for debugging purpose for testing methods.
*/

public class Main {
public class Test {
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException,
InstantiationException, NoSuchMethodException, InvocationTargetException {
Class c = Class.forName("Test");
Test t = (Test)c.newInstance();
Class c = Class.forName("TestClass");
TestClass t = (TestClass)c.newInstance();

Method m = c.getDeclaredMethod("show", null);
m.setAccessible(true);
m.invoke(t, null);
}
}

class Test {
class TestClass {
// private method: Can't be called from outside the class
private void show() {
System.out.println("In show");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class Main {
public class Test {
public static void main(String[] args) throws ClassNotFoundException {
Class c = Class.forName("A");
System.out.println(c.isInterface());
Expand All @@ -8,4 +8,4 @@ public static void main(String[] args) throws ClassNotFoundException {
}

class A {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../13.2 - Using Thread Class">
<sourceFolder url="file://$MODULE_DIR$/../13.2 - Using Thread Class/src" isTestSource="false" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- But since runnable interface is functional interface, this can be achieved using lambda expressions also
*/

public class Main {
public class Test {
public static void main(String[] args) {
Hi obj1 = new Hi();
Hello obj2 = new Hello();
Expand Down Expand Up @@ -58,4 +58,4 @@ public void run() {
try { Thread.sleep(1000); } catch (InterruptedException ignored) {}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../13.3 - Using Runnable Interface">
<sourceFolder url="file://$MODULE_DIR$/../13.3 - Using Runnable Interface/src" isTestSource="false" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- But since runnable interface is functional interface, this can be achieved using lambda expressions also
*/

public class Main {
public class Test {
public static void main(String[] args) {
Hi obj1 = new Hi();
Hello obj2 = new Hello();
Expand Down Expand Up @@ -49,4 +49,4 @@ public void run() {
try { Thread.sleep(500); } catch (InterruptedException ignored) {}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- for making code more efficient
*/

public class Main {
public class Test {
public static void main(String[] args) {
/*
1) Using anonymous class:
Expand Down Expand Up @@ -76,4 +76,4 @@ public void run() {
try { Thread.sleep(10); } catch (InterruptedException ignored) {}
t2.start();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class Main {
public class Test {
public static void main(String[] args) throws InterruptedException {
Thread t1 = new Thread(() -> {
for(int i=0;i<5;i++) {
Expand Down Expand Up @@ -34,4 +34,4 @@ public static void main(String[] args) throws InterruptedException {

System.out.println("Is t1 alive: " + t1.isAlive());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// join method: will wait for the thread to complete execution and join parent thread
// isAlive method: returns true if thread is alive

public class Main {
public class Test {
public static void main(String[] args) throws InterruptedException {
Thread t1 = new Thread(() -> {
for(int i=0;i<5;i++) {
Expand Down Expand Up @@ -29,4 +29,4 @@ public static void main(String[] args) throws InterruptedException {

System.out.println("Is t1 alive: " + t1.isAlive());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class Main {
public class Test {
public static void main(String[] args) throws InterruptedException {
Counter c = new Counter();

Expand Down Expand Up @@ -39,4 +39,4 @@ public void increment() {
public synchronized void increment() {
count++; // count = count + 1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- can only be called from a synchronized method
*/

public class Main {
public class Test {
public static void main(String[] args) {
Q q = new Q();
new Producer(q);
Expand Down Expand Up @@ -71,4 +71,4 @@ public void run() {
try { Thread.sleep(2500); } catch (InterruptedException ignored) {}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
LinkedHashMap
- keys ordered in insertion order
*/
public class Main {
public class Test {
public static void main(String[] args) {

// HashMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Map;
import java.util.Set;

public class Main {
public class Test {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
map.put("name", "Navin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import java.util.HashSet;
import java.util.Set;

public class Main {
public class Test {
public static void main(String[] args) {
ArrayList<String> names = new ArrayList<>();
names.add("Rahul");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.ArrayList;

public class Main {
public class Test {
public static void main(String[] args) {

// Calculating time taken to add 1000000 elements in the ArrayList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.io.Serializable;
import java.util.ArrayList;

public class Main {
public class Test {
public static void main(String[] args) {

// Testing our own Generic
Expand Down Expand Up @@ -61,4 +61,4 @@ public void demoExtends(ArrayList<? extends T > obj) {
// super: Will accept all classes including Number and it's parent
public void demoSuper(ArrayList<? super T> obj) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Collections;
import java.util.List;

public class Main {
public class Test {
public static void main(String[] args) {
// Using Collection interface
Collection<Integer> values = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.ArrayList;
import java.util.Vector;

public class Main {
public class Test {
public static void main(String[] args) {
Vector v = new Vector();
v.add(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Comparator;
import java.util.List;

public class Main {
public class Test {
public static void main(String[] args) {
// 1) sort values normally
List<Integer> values = new ArrayList<>();
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.