Website/App design एवं college projects आदि के लिए संपर्क करें – 8085589371

इस article में हम पढ़ेंगे –

Variable

Variable एक container या box है जिसमे value को store करके रख सकते है, जिसे हम बाद में change (program लिखने के दौरान या program run करने के दौरान) कर सकते है।

public class Main {
    public static void main(String[] args) {
        
        /**
        * x is a variable
        * = is an operator
        */
        
        int x = 10;
        System.out.println("value of x = "+x); 
        
        /*
        * x is changed
        */
        x = 12;
        
        System.out.println("value of x = "+x); 
    }
}

Constants

Variable एक container या box है जिसमे value को store करके रख सकते है, जिसे हम बाद में change नहीं (program लिखने के दौरान या program run करने के दौरान) कर सकते है।

public class Main {
    public static void main(String[] args) {
        
        /**
        * x is a constant
        * = is an operator
        */
        
        final int x = 10;
        System.out.println("value of x = "+x); 
        
        /*
        * error 
        */
        x = 12;
        
        System.out.println("value of x = "+x); 
    }
}

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top