Proper convention for blocks of code in Java [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I may be stupid for asking this but... I don't know if I should format blocks like this:
public void elbow() {
System.out.println("Elbow");
}
or:
public void elbow() {
System.out.println("Elbow");
}
or are both correct?

Both are correct. It is a matter of preference. Most guys I work with like to be able to see more code on a single screen so opt for the first, within reason.
You may also mix them if you have a long loop it may be good to place whitespace at your own discretion to improve readability.

Related

Is it possible to use IPOPT without Jacobian matrix? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
I am writing a program with IPOPT in Java and due to the nature of the problem, it is rather difficult to provide a Jacobian matrix.
The question is basically the title:
Is it possible to use IPOPT without Jacobian matrix and if so how?
i couldn't find anything in the documentation, but maybe i am just blind.

is "get" the right prefix for a service's method that queries a DB? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I'm writing a method that given a product, returns for each country the number of sales. I named it getNumOfSalesByCountry().
To me, the word "get" relates to a getter of a bean and not to a function that makes a query to a DB.
Can you suggest better names? (Or you think the name is valid)
Thanks
You can name it something like retrieveNumOfSalesByCountry(), but I think getNumOfSalesByCountry() is good too.

Calling original method in overloading [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Is it a good practice to overload method in Java, calling this original method inside a new one but passing some default values as parameters for original method?
As the commenters noted, this is a standard practice. Typically, it is used to allow simplified signatures in order to provide default values. Like any other, pattern, some thought should be taken to avoid abusing it.

huffman without using node [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm thinking on possibility of making a Huffman code without "node".
It's based on the nodes then my question seems a bit ambiguous.
I know,maybe we have to use string's abilites ...
Is it possible ? and if "YES" how Is it possible in java?
Thanks.
You can use indices instead of nodes but you need somewhere nodes and/or vertices.

Why do we need static methods in interfaces Java 8? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Why? Isn't this kind of anti-pattern?
This makes it easier for you to organize helper methods in your libraries; you can keep static methods specific to an interface in the same interface rather than in a separate class.
Please read this

Categories

Resources