answersLogoWhite

0


Best Answer

The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.

The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.

The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.

The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.

The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.

The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.

The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.

The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.

The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why do you need to write brackets after such command as getName in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a '' called in java?

brackets


How do you write and execute java program?

In theory, you can write a Java program in just about any text editor; then you can compile it with the "javac" command, and - if the compilation works without errors - run it with the "java" command. In practice, and especially for new programmers, I would recommend that you get a good Java IDE, which lets you do everything in a single environment, and clearly shows where there are errors, among other benefits.


How do you write and execute the java program?

In theory, you can write a Java program in just about any text editor; then you can compile it with the "javac" command, and - if the compilation works without errors - run it with the "java" command. In practice, and especially for new programmers, I would recommend that you get a good Java IDE, which lets you do everything in a single environment, and clearly shows where there are errors, among other benefits.


What is a function in java?

The term equivalent to functions in Java is "methods". Methods are pieces of code that are used to make some functionality. Ex: public String getName(){ return "Anand"; } The above is a sample method


What is the need of separators in java?

Separators are the characters which stands for puncuations in java such as brackets,braces etc


How do you run a java program form the command prompt?

The command is "java", followed by the class name. For example, if your compiled class is called myclass.class, you give the command: java myclass


Command use on how to run a java program?

You execute it the same way you would on any other OS. As long as you have the Java Runtime Environment installed and the "java" executable is in your path, from the command line you would simply run: java -cp /path/to/file/here com.some.class.to.run.Here


What is command to compiler java program?

The command is "javac".


What is member variable in java?

We use the term member variable to refer to variables that are defined inside a method. Ex: public String getName(){ String x = "ttt"; ..... } In the method getName() x is a member variable


How do you execute a Java program?

You can run a Java application from the command line using "java <name of the class>"


What is the command to compile a java program named Greetingsjava?

The command to compile a Java program is "javac", followed by the class name (file name).


Ax plus b equals 0 in java?

Java won't solve equations for you. Do the algebra with pencil and paper; in this case, I assume you want to solve for x. Then write a command to calculate the value, and assign it to x.Java won't solve equations for you. Do the algebra with pencil and paper; in this case, I assume you want to solve for x. Then write a command to calculate the value, and assign it to x.Java won't solve equations for you. Do the algebra with pencil and paper; in this case, I assume you want to solve for x. Then write a command to calculate the value, and assign it to x.Java won't solve equations for you. Do the algebra with pencil and paper; in this case, I assume you want to solve for x. Then write a command to calculate the value, and assign it to x.