Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Java (not to be confused with JavaScript) is a class-based, object-oriented, strongly typed, reflective language and run-time environment (JRE). Java programs are compiled to bytecode and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.
10
votes
Accepted
Vertically placing the words in a string
Looking at this code:
if(strTemp.length() > maxWordLen)
maxWordLen = strTemp.length();
This could be reduced to:
maxWordLen = Math.max(maxWordLen,strTemp.length());
Inline the increment …
6
votes
Codility Frog Jump - Count minimal number of jumps from position X to Y
Maybe you should try something like:
public class Frog {
public static int solution(int x, int y, int d) {
return (int) Math.ceil((y - x) / (float)d);
}
3
votes
Palindrome program with reverse method
if (isPalindrome(integer) && (integer > 0 && integer > 9))
{
System.out.println(integer + " is a palindrome");
return;
…
3
votes
Find the maximum number of consecutive zeros in an array
In the addendum to aforesaid :
1 . The comparation (tempLength > maxLength) should be moved to the first if block. If current is not zero, then tempLength is obviously not greater than maxLength, and …
2
votes
Improve if-statement for multiple strings
You can build a method which pulls a String from request and check if it is empty:
private static String getString(Request request, String parameter){
String result = request.getParameter(parame …
2
votes
Reversing a string in-place - recursion or iteration?
Since Java does not support tail recursion, the function call cannot be optimized away. …
0
votes
Review implementation of boolean triple
Try this:
public class TribleBool {
public static void main(String[] args) {
boolean a, b, c;
for (int i = 0; i <= 7; i++) {
int x = i;
a = (x / 4) > 0;
…