Class Structures, Variables, Methods & Class Names


Class Structures

  • There are 2 class structures in Java namely, Class Structure & Main Class Structure.

This is a chart that shows you the difference between a class Structure & a Main Class Structure.


               
In the above figure these are the highlighted parts...
  • Red- Variables
  • Silver- Class name
  • Blue- Method
  • Yellow- Main Method [in main class structure]

  • When we are starting  class we're using open curly brackets-- {
  • When we are starting a method we use closed curl bracket-- }
  • We use a semicolon when ending a code line-- ;
  • We're using parameters to store the data-- ()


Class Names

Examples for class names-; class Axel
                                             class Apple

  • We can give any name to a class.
  • We're using an uppercase letter for the 1st letter of the class as a standard but not as a law.


Variable 

  Examples for variables-; galex
                                          menston

  • We can use any name as a variable.
  • When we're making variables in Java we usually use a lowercase letter as the 1st letter of a variable
  • We don't keep spaces  within letters in variables.
  • We're using a semicolon after writing the variable in Java codes.
Example-; Dissanayake | Thisum

In this example the green colored highlighted part is  class\class type.
                                yellow colored highlighted part is a variable.

Method

Example-;            void test ()
                             public void demo ()

                          
In this code piece, Orange color highlighted words are, return types.     
                              Yellow  color highlighted words are, method names.
                              Light purple color highlighted symbols are, parameters.
                              Light red color highlighted word is an access modifier.

  • No spaces are allowed in methods as a law.
  • We can use any name as a method.
        -(1st Article)
                                                           Thank You!                                                                                                                               
                            

                                                                                                           


                                                                                                            
                     
                                                                                            -Article about Java by Hirun Yapa

                  
               

Comments

Post a Comment

Popular posts from this blog

Interfaces

Super Keyword

Abstract Classes