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 byte-code and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.

learn more… | top users | synonyms (2)

0
votes
0answers
7 views

How can you add values to an array in a serpentine like fashion? [on hold]

My overall goal is to create a minimum Difference method that separates a group of numbers (represented in ArrayList list) into even (or at least as even as possible) teams. I.E. as shown below, there ...
1
vote
0answers
22 views

Java 8 file read method

I have a method which extracts filedata and converts it into a String array: ...
6
votes
2answers
27 views

Age in years at a specific date

For eligibility to events I need to know the age of a competitor at a specific date. Now the thing is the date calculations are checked in two places, an online PHP app where the entries are ...
3
votes
1answer
20 views

Simulating a GUI windowing system - follow-up

The previous and initial iteration at Simulating a GUI windowing system I have essentially cleaned the code based on the only answer. Now I have: MyCanvas.java: ...
4
votes
1answer
29 views

Parsing error messages using regular expressions in Java 8

I have a below method in Java 8 which checks for message pattern and finds the line number from the message. ...
2
votes
1answer
25 views

Safe Thread Synchronization

I think the following is thread safe. Am I right? How would you improve this code? Are there new APIs or methods I can use? Data: ...
10
votes
2answers
400 views

Printing removed items using lambdas and streams

I'm struggling to make my lambdas readable. I've seen various approaches. Below are three different examples that all do the same thing. Forgive the example: I suspect there are better actual ...
7
votes
4answers
1k views

Palindrome program

Given a beginning and ending point, check how many numbers are palindromic. My solution is a bit clunky. How could it be more elegant? ...
0
votes
0answers
16 views

Unit test for running a query, using Mockito

What's happening here is we are testing QueryRunner.RunQuery(ANBQuery q) The method calls methods of two other objects, ...
6
votes
3answers
149 views

Stack with getMin method

This should implement a stack that has a \$O(1)\$ getMin method. I used an auxiliary stack. Please provide comments on my solution. ...
3
votes
1answer
39 views

Deciding whether an anchor should be updated

A colleague and I were discussing the following code today and had a disagreement over the return false in the ...
-2
votes
0answers
15 views

How to continuously inject objects into spark streaming + SQL [on hold]

I am trying to migrate from Esper to either Spark or WS02. The problems I have been having with spark are manifest (apparently 3.0 APIs are just a complete mess). But given a previous version I have ...
9
votes
1answer
400 views

Beginner text editor

I wrote a simple text editor and I would like to get some critical comments. Below I present only a main part of code. I removed icons, irrelevant functions, etc. I am aware,that JTextArea is not best ...
2
votes
0answers
20 views

Update on tileMap Class

This is an update from An Update on my TileMap Class. It's a tileMap class for a Top-down old-school final fantasy game. User Tim gave me suggestions and I updated some of the code accordingly. ...
8
votes
4answers
451 views

Calculate Digital Root

Here's my solution for finding the digital root of a number. Just for purposes of completion, a digital root is: "If you take the digits of any number and add them together, and then add the ...
3
votes
1answer
69 views

Android App Interview (Minesweeper game)

I recently did an Android Minesweeper app for a pre-interview coding challenge before I could talk to any engineer and was rejected. This feedback was given but I'm not sure on some of it. ☺︎ Game ...
3
votes
1answer
17 views

An Update on my TileMap Class

I'm making a old-school Final Fantasy type game and I made a tile map class a while back and posted it on here (Is this a good way to implement a tile map from a text file?) But, when I got to ...
-1
votes
2answers
90 views

Searching for an account by accountId

I have a piece of code that is fetching account objects from a service ...
3
votes
1answer
53 views

Java class that generates a short URL string for an input string

Help me find out if the approach I took to generate random strings here is correct to be able to return the appropriate short URLs. ...
4
votes
2answers
242 views

Efficient use of MySQL Connections with Java

Background: I'm building a dynamic in-house on-call roster that will be displayed on a web page. The end user will be displayed a list of people who are currently (at the time of the database call) ...
3
votes
2answers
111 views

Ulam numbers (calculates your life expectancy if you want to)

I'm new to Java and wanted to present to you my latest project: Ulam Numbers ...
3
votes
1answer
34 views

Webserver for handling GET and HEAD requests

I have a programming assignment where I need to build a webserver which can handle GET and HEAD requests. My webserver is working as it should but since I'm still a newbie at Java I'm not sure about ...
3
votes
2answers
48 views

Java function that blocks until a specific file is deleted

Created for a console application that will be run in the background on a linux system, giving me a nice way to gracefully shut it down by simply deleting a file (which can be done via script/etc.) ...
5
votes
2answers
112 views

Project Euler #4 Largest Palindrome Product

I'm kinda new to Java (<1 year) but have some background in C and Python. I've come up with a working solution to Project Euler Problem 4 - Largest Palindrome Product. However, I'm not confident ...
0
votes
0answers
22 views

Add list obj to list obj [on hold]

i'm newbie in java, learning to do some staff with collection, etc. My task is, add list of student's which i've input from keybroad to group. And dont have any idea, how to realize it. So, shall i've ...
5
votes
3answers
169 views

Performing several integer division operations on an array

Program: Given an array A of size N. Given Q operations, each operation contains an integer D. In each operation you have to divide all the elements of the array by D. For example, ...
0
votes
0answers
13 views

Remove elements from an array [on hold]

I'm trying to do a code which works with arrays, the thing is that I need to do a method delete(Object e) which has to delete all the objects in the array that equals "e", the thing is that I can't ...
3
votes
2answers
242 views

Evaluating an expression with integers, +, and *, as well as -, /

There is a job interview question, and the source of the question is here. The solution is pretty simple. We just need to split the input string by + and then by *. Then we compute products in a ...
5
votes
1answer
40 views

Sort a stack in ascending order

Sort a stack in ascending order. You may only use one additional stack to hold items. Any comments on my solution? Worst case complexities: Memory complexity: O(n) Runtime complexity: O(n^2) Also, ...
3
votes
3answers
134 views

Implementing sequence abstraction

Below is the code that implements sequence abstraction using type abstraction Sequence (in Java): ...
2
votes
1answer
19 views

Candy splitting - lower memory usage needed

I just did CodeChief's candy splitting task here and my code is working even with a lot of test cases and big numbers, but it uses way too much memory. When I checked my submission, it was 1342M, ...
3
votes
1answer
100 views

Shortest path using Breadth First Search

I have sample graphs like the following(Un-directed un-weighted cyclic graphs). My goal is to find shortest path between a given source and destination. ...
0
votes
1answer
37 views

Generate all permutations

I have written this Java snippet to generate all permutations of a given array of integers. Can somebody review it and give some pointers as to how to make it more generic? I.e. instead of dealing ...
11
votes
2answers
130 views

Object-oriented design for Wheel of Fortune

I'm trying to design the classes for the Wheel of Fortune game in Java. The below diagram represents the classes and the interaction between them. . Below is the partial implementation of it. I ...
3
votes
1answer
31 views

TurboSort challenge

I recently started to do some of the exercises in CodeChef and I did the TurboSort challenge here is it's description. It works fine with smaller arrays but can't pass some of the tests due to the ...
2
votes
0answers
19 views

Torus board effect for Game of Life

My task is to update the two methods that you constructed so that instead of the edge of the board being "dead", the edge of the board “wraps around” to the opposite side of the game board. ...
15
votes
1answer
57 views

Streaming Collatz

Challenge The recent question The 3n + 1 algorithm for a range inspired me to investigate a Java-8 dependent streaming mechanism for solving the programming challenge: For any two numbers ...
8
votes
2answers
321 views

The 3n + 1 algorithm for a range

Essentially the Collatz Conjecture. Challenge requirements are here. And here is my implementation in Java: ...
5
votes
2answers
149 views

Matching words with a scrambled word

I have this code that reads in a "scrambles" and a "words" file. It compares both files using their canonical form and prints out the words from the "words" file that match a particular scrambled ...
2
votes
1answer
13 views

Updating a JavaFX ListView after service update

I wrote a JavaFX program that contains a list of notes, each having a title and a content. This is the controller code: ...
5
votes
3answers
105 views

Savings account class and test program

My code is complete. It runs properly and produces the correct output. I did calculations by hand to check and then ran the program and it gives me the same result. I just want a second opinion. Are ...
-2
votes
0answers
23 views

Code attempts to find the largest prime factor of the number 600851475143 [closed]

I ran into some problems when trying to use long to store the number so I decided to use BigIntegers (which i'm not really familiar with). But here's my code, and whenever I try to run it, the code ...
2
votes
1answer
58 views

Finding the common prefix in a list of strings

Given a list of strings, my task is to find the common prefix. Sample input: ["madam", "mad", "mast"] Sample output: "ma" ...
0
votes
0answers
20 views

Changing DICOM tags using dcm4che

I am stuck on a piece of code that I have written that uses dcm4che. I have made a whole heap of nested ifs and I want to find a way to convert to a switch-case (problem being I have no way of ...
8
votes
5answers
585 views

Custom Logging Class: Efficiency

I wrote a logging class for several of my applications, but I have noticed that it is fairly in-efficient. Can anyone suggest improvements? What I am looking for: Pointers on improving efficiency ...
1
vote
0answers
42 views

Android calculator app

I am new to android developement. Created calculator application. Want to improve my code quality. Will be helpfull for any advice to make the code better and more professional (overall structure, ...
-5
votes
0answers
23 views

Java : Need help making my code more efficient [closed]

Need help with the following task, cannot seem to get my code working and have been trying for a long time now
0
votes
1answer
48 views

Eigenvalue calculation for a Java matrix library [closed]

After an interview didn't go smoothly, I decided to write my own library so that I would be better prepared if I'm ever asked about matrix multiplication again. I know that doing it in Java is going ...
5
votes
1answer
27 views

Triangulate the divisors and divide the triangulars

Project Euler 12 - Highly divisible triangular number The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be \$1 + 2 + 3 + 4 + 5 + 6 + 7 = ...
6
votes
1answer
62 views

Taking flight with JavaFX

Just another step in my educational Trek. I didn't know when/why I would use the transparent feature and in experimenting with it, I made this. This one was fun to behold once done. It's an animated ...