Showing posts with label What is Separator in java. Show all posts
Showing posts with label What is Separator in java. Show all posts

Friday, 16 November 2018

separators in java | what is separators in java - online help

Separator in java:

Let's discuss what is a separator in java and what are all the types of separators available in java. let's get started. A separator is a symbol that is used to separate a group of code from one another is called as separators in java. In java, there are few characters that are used as a separator. The most commonly used separator is a semicolon. As we have seen it is used to terminate the statement.

For example, items in the list are separated by commas in a sentence like lists of items in a sentence. In Java language, it has six types of separators. They are:

S.NO
MEANING
SYMBOL
PURPOSE
1
Parentheses
()
Used to enclose an argument in the method definition. Also used for defining the expression in control statements.
2
Braces
{}
Used to define a block of code for classes and methods. Also used to contain the values of arrays.
3
Brackets
[]
Used to declare an array type. Also used when dereferencing array values.
4
Semicolon
;
Used to separate or terminate the statement.
5
Comma
,
Used to separate identifiers (or) Variable declarations. Also used to chain statements together inside a for a statement.
6
Period
.
Used to separate package names from sub-packages and classes. Also used to separate a variable or method from a reference variable.




Sample program for separator in java:

class separator
{
public static void main(String args[])   // uses bracket or [] separator
{                           // uses braces  or {} separator
int a=10,b=15,c;   // uses comma or , separator
c=a+b;                // uses semicolon or ; separaotor
system.out.println("addition of a and b is:"+c)     // uses  paranthesis or () separator
}
}

The output is:
addition of a and b is:

Also Read: Thread in java