Posts

oops.

 copy constructor -  package program ; import java . util .* ; class demo { int a , b ; demo ( int a , int b ){ this . a = a ; this . b = b ; System . out . println ( a + " " + b ); } demo ( demo ref ){ a = ref . a ; b = ref . b ; System . out . println ( a + " " + b ); } } public class code {     public static void main ( String [] args ) {     demo d1 = new demo ( 10 , 20 );     demo d2 = new demo ( d1 ); } } private constructor -  package program ; import java . util .* ; public class code { int a ; String s ; private code (){ System . out . println ( a + " " + s ); }     public static void main ( String [] args ) {     code d1 = new code (); } } constructor overloading -  // Constructor overloading program package program ; import java.util.* ; public class code { int a ; String s ; // private constructor private code (){ System . out . println (a + " " + s); } // Para...

file handling.

  package F ile_ H andling ; import java . io .* ; public class CreateFile { // public static void main(String[] args) { // File f= new File("C:\\Users\\vedva\\OneDrive\\Desktop\\ved.txt"); // try{ // if(f.createNewFile()){ //     System.out.println("file successfully created"); // }else{ //     System.out.println("file already exixts.."); // } // }catch(IOException e){ //     System.out.println("ioexception handled.."); // } //} public static void main ( String [] args ) throws IOException { File f = new File ( "C: \\ Users \\ vedva \\ OneDrive \\ Desktop \\ ved.txt" ); if ( f . createNewFile ()){   System . out . println ( "file successfully created" ); } else {     System . out . println ( "file already exixts.." ); } } } package F ile_ H andling ; import java . io .* ; public class FileInfo { public static void main ( String [] args ) { File f = new File ( "C: \\ Users \\ vedva \\ One...

Spring

Image
 

Tree in java

  package T rees ; class node { int val ; node left ; node right ; public node ( int val ){     this . val = val ; } } public class NodeTree { public static void main ( String [] args ) { node a = new node ( 1 ); node b = new node ( 4 ); node c = new node ( 3 ); node d = new node ( 2 ); node e = new node ( 6 ); node f = new node ( 5 ); a . left = b ; a . right = c ; b . left = d ; b . right = e ; c . right = f ; System . out . print ( "product of all nodes : " ); System . out . print ( product ( a )); System . out . println (); System . out . print ( "product of non-zero elements of nodes : " ); System . out . print ( product2 ( a )); System . out . println (); System . out . print ( "sum of all nodes : " ); System . out . print ( sum ( a )); System . out . println (); System . out . print ( "Maximum Node in tree : " ); System . out . print ( maximum ( a )); System . out . println (); System . out . print ( ...

Exception Handling.

Try Catch -> // Arithmatic Exception p ackage E xception_ H andling ; public class try_catch {     public static void main ( String [] args ) {         int a = 10 , b = 0 , c ;         try {             c = a / b ;             System . out . println ( c );         } catch ( ArithmeticException e ){             System . out . println ( e );         }     } } // NullPointer Exception package E xception_ H andling ; public class try_catch {     public static void main ( String [] args ) {         String s = null ;         try {             System . out . println ( s . toUpperCase ());         } catch ( NullPointerException e ){             System . out . ...