This challenge is related to the Java language. Note that challenges that require the answers to be in a specific language are generally discouraged.

learn more… | top users | synonyms

-1
votes
0answers
37 views

How can I make my memoization of a recursive search run faster (i.e. what am I doing wrong here)? [on hold]

I am trying to solve a problem in which you have to count the number of possible bar codes you can make given specific parameters. I solved the problem recursively and am able to get the correct ...
7
votes
6answers
287 views

Water Balloon Wars

This king-of-the-hill game is a strategy game in which you must throw around a water balloon and avoid getting splashed by water. The goal is to obtain the most points. You will be given a map of the ...
12
votes
8answers
4k views

Shortest code to throw IllegalArgumentException in Java

Okey, we all know the normal way to throw a IllegalArgumentException in Java: throw new IllegalArgumentException(); // 37 characters But there must be a shorter (as in less characters) ways to do ...
15
votes
9answers
1k views

Chess Tournament

This is a chess-KOTH with simplified rules (because chess itself is already complicated, playing it via a simple program doesn't make it easier). At the moment it is limited to java (version 8), but ...
0
votes
0answers
373 views

Is this the shortest possible Java quine? [duplicate]

Long ago, I found a Java quine online which uses a number of very clever tricks of the Java language (you can compile this at the command line, but it will not compile in most compilers--for obvious ...
87
votes
45answers
8k views

Survival Game - AlienWar

AlienWar This game takes place in a very crowded planet where aliens are the superior race. Your task is to create your own alien and beat all other. The Board It is a 2 dimensional board. The ...
14
votes
6answers
1k views

reach catch when everything in the try block is caught already

This is limited to Java and C# by the syntax I guess. In this programming puzzle, you are to produce Exceptions that can be caught but are thrown again at the end of the catch block. try { ...
182
votes
53answers
24k views

Survival Game - Create Your Wolf

The Board The Board is a two dimensional array of cells. Cells are populated by Animals. Every day, all Animals on the Board simultaneously make one move. If two or more Animals move to the same ...
-10
votes
2answers
681 views

Algorithm to find one unique number in one million and 1 numbers [closed]

I have been asked this question in an interview. In 1 million and 1 numbers, all the numbers having the duplicate except only one number. How to find that one number ? I got an idea to use EXOR gate ...
1
vote
0answers
272 views

fizzbuzz review [closed]

I'm newbie to Java and was trying out this FizzBuzz problem: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the ...
3
votes
1answer
593 views

Flip the commented-out code [closed]

This puzzle works for any programming language that has the same // single-line and /* ... */ multi-line comments that C++, C# and Java do. You are debugging an application. You find a fishy block of ...
-2
votes
3answers
2k views

Write a program to print squares of integers up to 25 in java without using variables?

I asked this question on programmers 10 days back but wasn't able to get the answer that I wanted. Write program in java to print the squares of first 25 integers(1-25) without using any variables. ...
10
votes
3answers
1k views

Write a java code to detect the JVM version

The objective is to write java code that detects the JVM version relying in compatibility changes, side effects, bugs and/or undefined behavior that works in a way in one version and another way in ...
5
votes
4answers
1k views

RPN calculator without pointers

Me and some other students were at a bar discussing programming languages, in particular the C programming language. At some point a first year student said he didn't need no damn pointers. Another ...
30
votes
17answers
4k views

Tips for golfing in Java

Are there any useful shortcuts that can be used in Java? As shown below, import already adds at least 17 characters to a program. import java.io.*; I understand that the simple solution would ...