answersLogoWhite

0

In java what is empty statement.Explain its usefulness?

Updated: 10/31/2022
User Avatar

Ashishniit2007

Lvl 1
14y ago

Best Answer

An empty statement in Java is just that: a statement with nothing in it. There are typically two ways to represent this:

  1. A single semicolon ;
  2. An empty block {}
The usefulness of this type of statement is limited. The main use that I can think of is to fulfill the statement required for a loop structure.

Here is an example that I recently used:

while (sf(++n) != i);

This loop will constantly call the method sf with increasing values of n until the return value of sf(n) is equal to i. Each loop in Java must have some code to execute in the loop body. In this case, all necessary work is done in the condition, and so the mandatory loop body is an empty statement.

While there may be other (more clear) ways of writing this bit of code, this is an example of where that empty statement can be used.
User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: In java what is empty statement.Explain its usefulness?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can you have an empty Integer value in java?

No. It has to be either NULL (Not yet Instantiated) or 0. Numeric objects cannot be empty.


What are the three parts of simple empty class?

Three parts of a simple empty java class are; A simple empty class of java supports legacy, as it automatically acquires object class, therefore can produce the functionality described in the object hierarchy. It automatically generates a fault constructor inside the class with a blank description. It also accompanies polymorphism, as can be practiced in any scheme by the extensive class.


What is the difference between Java 1.6 and Java 1.7?

Java 1.7 supports the features of 1.6 but introduces some new conventions:- Java 7 allows use of String object in the expression of a switch statement.- Auto-closing of resources (also known as try-with-resources)- Allow catching of multiple Exceptions- Allows underscores in Numeric Literal for readability (e.g. 1_234_567_890_123_456L)- Substitute the parameterized type of the constructor with an empty set of type parameters ()For full list see Java Programming Language Enhancements.


Does Visual Java plus plus and Java Builder is different from the Java language?

Yes!Visual Java plus plus and Java Builder is different from the Java language?


What are the different java technologies?

There are several types of Java technology. Some examples of Java software are Java ME, Java EE, Java SE, and Java Card. Java made the JAVA development kit for those that develop in Java. There is also Java Virtual machine and some class libraries. Java is also famous for its languages like Clojure, Beanshell, Groovy, Gosu, Rhino, Kotlin, JRuby, Scala, and Jython.

Related questions

Can you have an empty Integer value in java?

No. It has to be either NULL (Not yet Instantiated) or 0. Numeric objects cannot be empty.


Can you create an empty interface with no definitions?

Yes. This is a valid interface definition in Java: interface Useless {}


What is the usefulness of a company pospectus?

usefulness of a company pospectus


What is the suffix to efficient?

Usefully, usefulness.


What are the three parts of simple empty class?

Three parts of a simple empty java class are; A simple empty class of java supports legacy, as it automatically acquires object class, therefore can produce the functionality described in the object hierarchy. It automatically generates a fault constructor inside the class with a blank description. It also accompanies polymorphism, as can be practiced in any scheme by the extensive class.


What is the difference between Java 1.6 and Java 1.7?

Java 1.7 supports the features of 1.6 but introduces some new conventions:- Java 7 allows use of String object in the expression of a switch statement.- Auto-closing of resources (also known as try-with-resources)- Allow catching of multiple Exceptions- Allows underscores in Numeric Literal for readability (e.g. 1_234_567_890_123_456L)- Substitute the parameterized type of the constructor with an empty set of type parameters ()For full list see Java Programming Language Enhancements.


What is the usefulness of the teddy bear?

The usefulness of a teddy bear is to cuddle with it and let it feel like it's protecting you.


How do you use resourcefulness and usefulness in sentence?

Their resourcefulness helped them to get some tools which proved their usefulness when they started working.


What are the release dates for Usefulness at an End - 1908?

Usefulness at an End - 1908 was released on: USA: June 1908


What Indonesian island is Jakarta on?

java


Does Visual Java plus plus and Java Builder is different from the Java language?

Yes!Visual Java plus plus and Java Builder is different from the Java language?


What are the different java technologies?

There are several types of Java technology. Some examples of Java software are Java ME, Java EE, Java SE, and Java Card. Java made the JAVA development kit for those that develop in Java. There is also Java Virtual machine and some class libraries. Java is also famous for its languages like Clojure, Beanshell, Groovy, Gosu, Rhino, Kotlin, JRuby, Scala, and Jython.