Basics of java programming:
To write a java program, the following details, are need.
1. Command-line:
- It describes what's going on inside a program, so that person looking at the source code does not have a hard time figuring it out.
- That means human understanding and not be execute in output.
- Types of comments:
(i) Single line comments:
Syntax:
//Statements or Comment
(ii) Multiline comments or comments for combined in multi line:
Syntax:
2.Variables:
- A variable is nothing but it allocates the memory space and holds the values.
- That means every memory of address is difficult to use in the program, conversely, we give that address as a simple user-defined word or character is called variable.
- For example, each user dials the call using a contact name only not use the phone number. i.e. each user needs an easy way to access the phone number to make a call to others.
- Here, the phone number act as a memory address and saved details of contacts called variables(this process happens in CPU).
Syntax:
Data_type variable_name;
Example:
int x, y;
Rules for naming the variables:
- The first character must be an alphabet or an underscore(_).
- No commas or blank spaces are allowed within a variable name.
- No special symbols, an underscore can be used in a variable name.
Scope of variables:
- It implies the availability of variables within the program.
- It is divided into two types.
(i) Local variable:
- The variables which are defined inside the function block called a local variable.
Example:
public static void main (String args[])
{
int a,b;//local variable
......
}
(ii) Global variable:
- The variables that are declared before the main() a function is called a global variable.
Example:
int a,b;//Global variable
{
......
}
3.Data types:
- The data type is the type or kind of data, that is going to process within the program.
- The most widely used data types are
4. Input function:
- This function is used to get value from users.
Syntax:
Scanner object_name= new Scanner(System.in);
variable_name= scanner_object_name.input_type();
5. Input type:
- It is used to indicate unknown value for types to display on the output screen and also get value from the user. ( i.e. Holds unknown values).
There are,
6.Output function:
- This function is used to show details on the output screen for user understanding.
Syntax:
7.Escape sequence:
No comments:
Post a Comment