Operators in Java

Operators in Java:

Any symbols that is used to perform operations by logically or the values that operates the operands are called operators.

Different types of operators, they are

  • Arithmetic Operators
  • Relational Operators
  • Bit wise Operators
  • Logical Operators
  • Assignment Operators
  • Misc Operators

Operators Precedence:

Operators Precedence

Statements:

The Statements of a program in any programming language will by default execute in sequential order. We take the help of control statements.

The control statements are used for controlling the follow of execution in a program .Using which we can execute the statement in a random order according to programmer choice.

The Control statements in java language are classified into following category’s they are

  1. Conditional statements
  • If else statement
  • Switch statement

Syntax of  if and if else:

if(Expression){
statement1
}
elseif (Expression){
statement2
}
else{
statement3(default value)
}

2.Iterating statements

  • for loop
  • while loop
  • do while loop
  • for each loop

A for loop can be used for executing group of statements multiple times .The for loop should be used when we know the exact number of iterations. go with java online course

All three sections of for loop are optional .we do not initialize and do not specify. The increment and decrements section can contain any valid java statement.

Java

3.Transfer statement

  • break
  • continue
  • return

Example:code shows us break statement

Example of break statement

Strings in java:

A String object is created by using new operator then the content will be stored in both heap memory and string constant pool but the reference variable will point to the object available in heap memory.

String str = new string (“hello”);

String Object stored

If a string object is created by placing a group of characters enclosed directly the pair then the string object can be stored only in string constant pool.

String str=”hello” ;

Methods of string class

The java.lang.string class gives us a useful methods to perform the functionality of char values.This method will return the count of number of characters available in a string.This method will return in characters that is available at specified index position.

The index position of a string begins with ‘0’ if we specify the index value outside the range then we get called run time error called “String Index Out Of Bond Exeception”.

Methods of String

 

 

String Buffer:

String Buffer is a predefined class used for storing group of characters, the object can be created only in one way that is using new operator.

String Buffer Methods:

String Buffer MethodsString Builder:

String Builder is a predefined class used for storing characters, the string builder is a class introduced in java 5 version, the objects are created only in one way that is by using new operator.

String Builder sb=new String Builder (“hello friends”);

Array:

An application requires multiple values then we can store those multiple values by declaring multiple variables, if an application contain multiple variables then the code size will be increased and maintenance will be difficult.

The arrays are classified into two types

  • Single dimension array
  • Multi dimension array

Single dimension array:

A single dimension array will represent a group of values in the form of either a single a row or a single column.

Syntax :

data type array Name[ ] ;

Multi dimension array:

The multi dimension arrays in java will be represented in the form “array of arrays”

Syntax:

data type array Name [ ] [ ];

Subscribe
to our newsletter

Drop Us A Query

Trending Courses
  • Selenium with python
    Selenium with Python Training
  • As we know, that Selenium with Python Web Browser Selenium Automation is Gaining Popularity Day by Day. So many Frameworks and Tools Have arisen to get Services to Developers.

  • Deep learning course
    Deep Learning Course
  • Artificial Intelligence, Deep mastering (DL) is completely about, many levels of Representation and sort of abstraction. That guide to design a sense of Information like Images, sound and text format.

  • machine learning with python
    Machine Learning with Python Training
  • Over last few years, Big Data and analysis have come up, with Exponential and modified Direction of Business. That operate Python, emerged with a fast and strong Contender for going with Predictive Analysis.

  • Data science with R
    Data Science With R Training
  • Understanding and using Linear, non-linear regression Models and Classifying techniques for stats analysis. Hypothesis testing sample methods, to get business decisions.

  • data science with python
    Data Science with Python Training
  • Everyone starts Somewhere, first you learn basics of Every Scripting concept. Here you need complete Introduction to Data Science python libraries Concepts.

  • devops with azure
    Devops with Azure Training
  • As we Know Azure DevOps is a Bunch of Services, in guiding Developers. It contains CI/CD, pipelines, code Repositories, Visual Reporting Tools and more code management with version control.


100% Secure Payments. All major credit & debit cards accepted.