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);
	}
}
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

Save snippets that work with our extensions

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