We’ve got the funky names for the things in Java. Implicit and explicit parameters. What the hell is that. As a programmer you’ve probably used them multiple times before without even knowing it. Just the nice guys that made the language decided to give it a name so no-coders would find it difficult to learn; by the looks of things.

But yeah, I’m going to explain simply what an explicit parameter is and what an implicit parameter is.

/**
 * Created by Josh on 11/05/2016.
 */
public class ImpExpPar {
    // a number...
    private int number = 0;
    
    // a method to set the number from the outside world
    public void setNumber(int number){
        this.number = number;
    }
    
    // a method to spit the number back out to the world
    public int getNumber(){
        return this.number;
    }
    
    //Little constructor to make us an object
    public ImpExpPar(){
        
    }
    
    //The main method... to run everything
    public static void main(String[] args){
        
        // make a new object using our class...
        ImpExpPar exampleThing = new ImpExpPar();
        
        //then set this thing's number to 100
        exampleThing.setNumber(100);
        
    }
    
}

You can see that I’ve gone the normal course of making a class, a constructor, some methods to get and set, and made a main thingy.

So the last significant line of code is setting the exampleThing’s number to 100.

The EXPLICIT PARAMETER is 100. That’s because you are EXPLICITALLY saying the you want to input 100. No doubt’s about that is there?

The IMPLICIT PARAMETER, on the other hand, is the OBJECT you have specified before the setNumber method.

Also, note, “this” (used in the setter and getter methods) is also IMPLICIT. Additionally, the parameter in these methods “number” is EXPLICIT.

That should make your life easier!

Until next time, Josh!

Leave a Reply
You May Also Like

CPAGrip Tutorial: Start Making Money with CPA Marketing

When there are so many people making money with CPAGrip, it’s difficult…

5 Ways To Make Money without Leaving Your House

There’s a tonne of posts for teens and students out there showcasing…