Skip to content

Instantly share code, notes, and snippets.

@avizyt
Last active September 10, 2022 08:31
Show Gist options
  • Save avizyt/32d1b4bcca30aed61deef274750e1f44 to your computer and use it in GitHub Desktop.
Save avizyt/32d1b4bcca30aed61deef274750e1f44 to your computer and use it in GitHub Desktop.
Java Notes
Java Class has two primary elements.
1. methods
2. function
Together these called the member of the Class.
Method has return type such as String, Int
and there is a spacial type called void which means no value at all.
parameter:
This method requires that information be supplied to it from the calling method.this information is called a parameter.
```{Java}
public int numberOfVisitors(int month){
return 10;
}
```
Here the method signature is numberOfVisitors(int)
Rule for main class:
* Each file can contain only one public class
* The filename must match the class name, including case , and have a .java extension.
* If the java class is na entry point for the program, it must contain a valid main() method.
Keywords
1. Public: in main() method is called access modifier.
2. static: it binds a method to its class so it can be called bty just the class name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment