Snippets Collections
import java.io.*;

class Demo 
{
	public static void main(String[] args) throws IOException
	{
		File f = new File("D:\\Cyber.txt");
		if(f.createNewFile())
			{
				System.out.println("File Successfully Created");
			}
			else
				{
					System.out.println("File is Already Exist");
				}
	}
}
import java.io.*;

class UsingThrowsKeyword 
{
	public static void main(String[] args) 
	{
		File c = new File("d:\\Success.txt");
		try{
		if(c.createNewFile())
			{
				System.out.println("file Create");
			}
			else
				{
					System.out.println("file is already Exist");
				}
		}
		catch(IOException i)
			{
				System.out.println("Exception Modidied");
			}
	}
}
/*
 class removeWhiteSpace {    
    public static void main(String[] args) {    
            
        String str1="Remove white spaces of the String";    
            
        //Removes the white spaces using regex    
        str1 = str1.replaceAll(" ", "");    
            
        System.out.println(str1);    
    }    
}   
*/

class RemoveWhiteSpaces
{
	public static void main(String[] args){
		String str = "Remove white spaces of the String";
		str = str.replaceAll(" ","");
		System.out.println(str);
	}
}
/*class Aray 
{
	public static void main(String[] args) 
	{
		System.out.println("Start");
		int[] a = new int[5];
		a[0] = 100;
		a[1] = 200;								// 1). To store multiple values we use Array[] 

		a[2] = 300;								// 2). Each valu store in Array[] will be within the cell in an Array[] 
		a[3] = 400;								//every cell will be given an index
		a[4] = 500;
		System.out.println(a[0]);
		System.out.println(a[1]);
		System.out.println(a[2]);
	}
}*/

class Aray 
{
	public static void main(String[] args) 
	{
		int[] a = new int[3];
		a[0] = 1000;
		a[1] = 2000;
		a[2] = 3000;
		for(int i = 0; i<3; i++){
			System.out.println(a[i]);
		}



	}
class Demo 
{
	public static void main(String[] args) 
	{
				StringBuffer str = new StringBuffer("Technology");
				System.out.println(str);
				
				String str1 = str.toString();
				System.out.println(str1);


				// StringBuffer to String convertion


				// o/p -  Technology
				//		  Technology
	}
}

class Parent
{
	int ml(){
	System.out.println("Parent m1");
	return 200;
}
}
class Child extends Parent
{
	int m1(){
	System.out.println("Child m1");
		return 100;
		}
}
class Demo 
{
	public static void main(String[] args) 
	{
		System.out.println("Hello Wo");
		Child c1 = new Child();
		int a=c1.m1(); 
		
		// you are returning Parameters 
		//type int so Both Parent and Child method return type is same as primitive level.
		// ex boolean m1()- true
		//    boolean m1() - false is same as data type
		
		System.out.println(a);
	}
}
class  Sample 
{
	public static void main(String[] args) 
	{
		String str = "cyberee Success";

		// charAt() method is starting from zero and it will return charectar specified in this index.
		System.out.println(str.charAt(2));
		System.out.println(str.charAt(4));

		//The indxOf method will acept one of the argument charectar and it will return the index of the chaectar. 
		System.out.println(str.indexOf("b"));
		System.out.println(str.indexOf("z"));

		// In lastIndexOf() :- the last index print the last occerence of the spicified charectarwih the string.
		System.out.println(str.lastIndexOf("e"));
		System.out.println(str.lastIndexOf("s"));

		// If it not present then it will prent the value -1
		System.out.println(str.lastIndexOf("z"));
	}
}
class A 
{
	int a = 100;
}
class B extends A
{
	float b = 20.25f;
}
class C extends A
{
	char c = 'c';
}
class D extends A
{
	double d = 2000.25d;
}
class Demo2 
{
	public static void main(String[] args) 
	{
		A a1 = new A();
		System.out.println(a1.a);

		B b1 = new B();
		System.out.println(b1.a);
		System.out.println(b1.b);

		C c1 = new C();
		System.out.println(c1.a);
		//System.out.println(c1.b);
		System.out.println(c1.c);

		D d1 = new D();
		System.out.println(d1.a);
		//System.out.println(d1.b);
		//System.out.println(d1.c);
		System.out.println(d1.d);
	}
}
 class Parent
{
	void m1()
		{
			System.out.println("Inside m1 Method - Parent");
		}
}
 class Child extends Parent
{
	void m1()
		{
			System.out.println("Inside m1 Method - Child");
		}
	void add(int a,float b)
		{
			System.out.println("Inside add Method");
			System.out.println(a+b);
			this.m1();
			super.m1();
		}
}
class Demo 
{
	public static void main(String[] args) 
	{
		//System.out.println("Hello World!");
		Child d = new Child();
		d.add(10,20.2f);	
	}
}
// constructore overriding

class Overriding2
{
	Overriding2()
	{ 
		        System.out.println("Inside the Cons-1");
	}
			
	Overriding2(int a)
		{
				System.out.println("Inside the Cons-2");
		}



	public static void main(String[] args) 
	{
		System.out.println("Hello World!");
		Overriding2 src = new Overriding2(10);
	}
}
class RedBus
{
	void Payment()
		{
			System.out.println(" Inside m1 Parent");
		}
	void Payment(int card)
		{
			System.out.println("Inside m1 card");
		}
	void Payment(String upi)
		{
			System.out.println("Inside m1 string");
		}
	void Payment(String netUN, String netPluse)
		{
			System.out.println("Inside m1 2 string");
		}

	public static void main(String[] args) 
	{
		RedBus d = new RedBus();
		d.Payment("20","fg");

	}

}
class A 
{ 
	int a = 10;
}
class B extends A
{ 
	boolean c = true;
}
class C extends A
{ 
	char g = 'K';
}
class D extends A
{
	float b = 20.525f;
	public static void main(String[] args) 
	{
		System.out.println("Hello World!");
		A s1 = new A();
		System.out.println(s1.a);
		B s2 = new B();
		System.out.println(s2.c);
		System.out.println(s2.a);
		C s3 = new C();
		System.out.println(s3.g);
		//System.out.println(s3.c);
		System.out.println(s3.a);
		D s4 = new D();
		System.out.println(s4.a);
		//System.out.println(s4.c);
		//System.out.println(s4.g);
		System.out.println(s4.b);
		
	}
}
class A
{
	int x = 10;
}
class B extends A
{
	float y = 50.25f;
}
class C extends B
{
	char z = 'K';
}

class Inheritance 
{
	public static void main(String[] args) 
	{
		System.out.println("Hello World!");
		A s1 = new A();
		System.out.println(s1.x);
		B s2 = new B();
		System.out.println(s2.x);
		System.out.println(s2.y);
		C s3 = new C();
		System.out.println(s3.x);
		System.out.println(s3.y);
		System.out.println(s3.z);

	}
}
class EmployInfo
{int EmpId=10;
	float EmpSal=20;
EmployInfo(int EmpId,float EmpSal)
	{
		this.EmpId=EmpId;
		this.EmpSal=EmpSal;
	}
	void GetImpinfo()
		{
			System.out.println("Employ Information");
			System.out.println("Employ id is "+EmpId);
			System.out.println("Employ Sal is "+EmpSal);
			
		}
}
class Organisation 
{
	public static void main(String[] args) 
	{
		System.out.println("Hello World!");
		EmployInfo Emp1 = new EmployInfo(101,30000);
		Emp1.GetImpinfo();
		EmployInfo Emp2 = new EmployInfo(201,30000);
		Emp2.GetImpinfo();
		EmployInfo Emp3 = new EmployInfo(301,30000);
		Emp3.GetImpinfo();
	}
}
class Biba
{{
	System.out.println("Hi");
}
Biba()
{
	System.out.println("Inside Constructors");
	
}
Biba(int a)
	{
		System.out.println("Inside Constructors 1");
		System.out.println(a);
	}
	public static void main(String[] args) 
	{
		System.out.println("Start");
		Biba s2 = new Biba();
		Biba s3 = new Biba(45);
		System.out.println("Stop");

	}
}
star

Wed May 17 2023 15:05:53 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Wed May 17 2023 15:03:24 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Sun Apr 30 2023 19:54:11 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Sun Apr 30 2023 18:48:23 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Wed Apr 26 2023 17:56:41 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Tue Apr 25 2023 17:33:36 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Sun Apr 23 2023 17:08:20 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Sun Apr 23 2023 05:39:06 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Fri Apr 21 2023 11:28:25 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance #overloading
star

Tue Apr 18 2023 17:42:36 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance
star

Sun Mar 26 2023 17:51:02 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance
star

Wed Mar 22 2023 16:43:47 GMT+0000 (Coordinated Universal Time)

#instanceblocks #inheritance
star

Wed Mar 22 2023 06:37:12 GMT+0000 (Coordinated Universal Time)

#instanceblocks
star

Tue Mar 21 2023 17:17:59 GMT+0000 (Coordinated Universal Time)

#instanceblocks

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension