Java is a popular programming language and runtime environment which allows programs to run unchanged on most platforms. Not to be confused with JavaScript.

learn more… | top users | synonyms (1)

3
votes
1answer
21 views

Count the one islands in the matrix

What is an island? A group of connected 1s forms an island. For example, the below matrix contains 5 islands: {{1, 1, 0, 0, 0}, {0, 1, 0, 0, 1}, {1, 0, 0, 1, 1}, {0, 0, 0, 0, 0}, {1, 0, 1, 0, 1}} ...
7
votes
1answer
64 views

Ready? Set. Fight!

Description This code is for 'fighting' two objects against each other. I am normally using it to make my AIs fight each other in one game or another. In case you are wondering: Yes, I am using this ...
5
votes
2answers
43 views

Checking brackets nesting in a string

I took a training challenge on Codility that checks for the proper nesting of brackets in a string. The brackets to be checked are {,},(,),[,]. I have written the following Java program which passes ...
3
votes
2answers
52 views

Fast edit of Excel file

I have this code to edit certain cells in my Excel file using Apache POI, but it is really slow. How can I improved the performance? Ideally I would like to edit 20000 rows in less than one minute. ...
4
votes
2answers
68 views

Trie (tree form) in Java

I created a Java Trie as part of a project someone challenged me to do. I'm not sure that this is the most efficient way to go about producing a Trie, I know that this works but I was hoping someone ...
3
votes
2answers
65 views

Permutation of a string eliminating duplicates

This code lists the permutations of the string, and eliminates duplicates if any. I'm looking for code review, best practices, optimizations etc. Also verifying complexity: O(n! * n) as time ...
2
votes
1answer
48 views

Bloom filter implementation

Implementation of Bloom filter with add and contain functionality. I'm looking for code review, best practices, optimizations etc. Also verifying complexity: O(1) public class BloomFilter<E> ...
7
votes
3answers
182 views

Sieve of Erathostenes optimization

I am making a program to find primes between the given range of numbers. Unfortunately, the algorithm I created is too slow. Do you have any ideas of how to optimize the code? import java.io.*; ...
3
votes
1answer
38 views

Is it ok to pull out specific arguments from a Java dynamic proxy invocation?

I have a Java dynamic proxy with an invoke method that looks like this: @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object result; try { ...
1
vote
2answers
88 views

Print the elements of an array into a table

I am trying to print the elements of an array into a table, but I'm having trouble formatting the array elements itself. Perhaps there is a better solution than what I'm currently using? import ...
0
votes
1answer
65 views

Reversing a 64 bit Integer [on hold]

Example: 00010111 -> 11101000 public long reverse(long x) { long r = 0; int i = 0; while (x > 0) { int bit = 0x0001 & x; r += bit << (63 - i); x ...
0
votes
2answers
33 views

Calculate all possible combinations of given characters

I was asked in my textbook Lectures on Discrete Mathematics for Computer Science to construct a program that would take an alphabet ({a,b,c} or any combination of characters {1,4,s,a}) as well as a ...
5
votes
2answers
114 views

Print routes on the stairway when only 1 or 2 steps are possible

Given a staircase with N steps, you can go up with 1 or 2 steps each time. Output all possible ways you go from bottom to top. I'm looking for code review, best practices, optimizations etc. ...
5
votes
3answers
68 views

Client Sends XML, Server Parses XML, Queues Up and Executes Commands

I recently had a Java interview where I was asked to write a client-server application. I don't code primarily in Java, but with my preliminary Java knowledge, I thought I built a reasonable working ...
2
votes
2answers
134 views

Fibonacci series, topdown and bottom up approaches, stairway climbing

I have solved fibonacci series and then used the topdown and bottom up approaches to solve it. Also I have included the stairway climbing question as follows "You are climbing a stair case. Each time ...

15 30 50 per page