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

-3
votes
0answers
86 views

how can i achieve this in java? [on hold]

A special purpose sorting machine takes text comprising of words and numbers, as input and sorts them both in ascending order and prints them in a manner that a word is followed by a number. Words can ...
-6
votes
0answers
101 views

Algorithm failing for only 2 test case in hackerrank [closed]

I tried to attempt hackerrank problem of https://www.hackerrank.com/challenges/poisonous-plants and come up with below algorithm. I require some help as my solution is failing only 2 test cases and ...
5
votes
0answers
244 views

Tricky interview puzzle: get longest sequence by flipping 1 bit [closed]

A friend of mine got this question during an interview. The interview ended with no luck for him, but still, we're very curious to hear the solution. The question is as follows: Modify the code below ...
11
votes
5answers
749 views

Risk, the Warlight Way

Introduction In this game, players use their armies to fight other players' armies, capture territories, and become the last man standing. Each turn, players receive a base number of armies to use at ...
10
votes
11answers
545 views

Rocket Bots KOTH

Rocket Bots The year is 3024. People have become too scarce a resource to risk in war, so combat has shifted to the robots. Your task is to construct a bot like no other, who's rockets will rain ...
9
votes
7answers
469 views

Simple Pazaak (Star Wars Card Game from Knights of the Old Republic)

Pazaak is a card game from the Star Wars universe. It is similar to BlackJack, with two players pitted against each other trying to reach a total of twenty without going over. Each player has a "side ...
21
votes
9answers
1k views

King of the Hill - Liar's Dice

Liar's Dice is a fairly simple dice game. I've seen a few different variations of the rules, but here is the version I'm most familiar with: Each player starts with 5d6 Except when tallying the dice ...
21
votes
12answers
714 views

The Great Wumpus Hunt

COMPLETE Wumpus season has ended, and with, the lives of many a vicious Wumpus and brave Hunter. As well as some cowardly, immoral and downright stupid Hunters. But at the end of the day, ...
15
votes
9answers
596 views

Asymmetrical KOTH: Catch the Cat (Catcher Thread)

Asymmetrical KOTH: Catch the Cat UPDATE: The gist-files are updated (including new submisisons) as the Controller.java did not catch Exceptions (only errors). It does now catch errors and exceptions ...
13
votes
9answers
567 views

Asymmetrical KOTH: Catch the Cat (Cat Thread)

Asymmetrical KOTH: Catch the Cat UPDATE: The gist-files are updated (including new submisisons) as the Controller.java did not catch Exceptions (only errors). It does now catch errors and exceptions ...
35
votes
20answers
3k views

Strategic Voting, The Game

One of the most common voting systems for single-winner elections is the plurality voting method. Simply put, the candidate with the most votes wins. Plurality voting, however, is mathematically ...
-1
votes
2answers
183 views

Java Package Correction

I have a lot of java projects and I am often making new ones. I have a few helper classes (Vector, Logger, etc.) and it takes a lot of time correcting the first line to the correct package, I would ...
4
votes
7answers
726 views

King of the Hill: Robot Battle

Your task here is to write an AI for a simple robot battle. The class to be implemented is provided at the bottom of this post, and source of the controller can be found here. Requirements Write a ...
20
votes
6answers
745 views

That's BS! (card game)

BS is a card game where the object of the game is to lose all of your cards. A game consists of four players and a 52-card deck. Each player is randomly dealt 13 cards. Normally, cards are labeled 2 ...
12
votes
8answers
744 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 ...
13
votes
8answers
6k 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
392 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 ...
89
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 { ...
190
votes
52answers
27k 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 ...
1
vote
0answers
308 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
645 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 ...
-1
votes
3answers
3k 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. ...
13
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 ...
32
votes
18answers
5k 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 ...