What is boilerplate code ? and How to write boilerplate ? (ch 01)

Chapter 01 :- Java Boilerplate Code


In our java class, If some topics is not understandable then escape it, we learn all topic in detailed in OPP's. So now just focus on your practical programming work and improve your ideas and build logic it is very important to build logic.

Now first we can define a class:
Example:-     public class fileName{
                     }

So don't get confused with that we can learn this topic on detailed if you have any doubt then ask me in comment section.

Syntax:- AccessModifier class fileName/className{

}
Note:- In our java className or fileName must be same keep this in your mind.

this is the syntax of our java boilerplate code, Public is AccessModifier and there are total four AccessModifier.

1)Public (Visible for all users) 80% to 90%  we only use public.
2)Private 
3)Protected
4)Package-Private (Default)

Boilerplate is class method, We write our whole code in our method body or Inside a Java class.

Class is like a classroom, and Student is like a Code or Set of Syntax. In classroom, students do there home-works and many more in classroom. So classroom is the name of our code that what we do inside the class, and students is the code that we should write in classroom. 

 

Here we are going to do next step of coding, now we can write a code inside the our class.

                        Example:-      public class fileName/className{
                                                    public static void main(String[] args){
                                                        
                                                    }
                                                }   

Don't get confused, this is just a function. It can execute whatever you write in  code.
  • main :- It's a Function Name(in every program main function is needed because without the main function the program is not execute. Every time when you run the code or compile the code first it find the main function in your code, if it doesn't found the main then its throws the error).
  • void :- void is Return type (Learn this topic in next part).
  • static :- static is keyword (there are many keywords but we used static in our boilerplate there is some reasons, the main reason is that, if we assign some variable double then it throws the error. It's because of that static means constant or not changable, thats why we are assign this some times we doesn't remember, what we assign or assign or not, that time it shows an error. So we can easily found it).
  • public :- I explained you, Now give me the answer in comment, What is public?.
  • String[] args :- In our code we also get some alphabetical values(Set of alphabets is called String) thats why we use String.
 Whole function topic is covered in this.

If you have any query or doubt then ask me in comment box, if you want in detailed.

Note :- This is mendatory to write in every program before writing function this is called boilerplate code. This is the boilerplate code of java. Now you fully understand the basic knowledge of boilerplate code. 





  

Comments

Popular posts from this blog

How to get Output ? How to write output program ? (ch 02)