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
2 views

Vigenere Cipher

i am studying about vigenere cipher in my college. I found this code in someone else journal. Then, i am trying to understand about the code. This is vigenere cipher using ASCII. The question is : ...
1
vote
2answers
16 views

Delay to avoid cocurrent modification

I was attempting to remove items from an ArrayList while iterating through it, only to find out that Java doesn't like that. So I quickly wrote up a ...
3
votes
1answer
21 views

Group lines from the csv file

I have a CSV file which looks like the snippet bellow ...
1
vote
2answers
116 views

Accepting a positive integer from either a command-line argument or System.in

I've been doing a lot of programs for classes that require a prompt from the program. I thought it would be much faster for me to rapidly test inputs if I didn't have to execute the program and then ...
16
votes
3answers
1k views

Java Inventory System

I'm often applying to jobs just to test out my skills. I have recently applied to one, had to submit a Java problem, but got rejected. Could someone please review my application briefly and tell me ...
7
votes
1answer
82 views

Learning by translating - Follow the Rubberduck - Part 2: Beta

This project is my learning place for a few things: MVP (model view presenter) XML (parsing, editing and leveraging) deeper swing functionality Concerning the XML part I have already recieved a ...
1
vote
1answer
32 views

Finding overlapping time intervals for two games

I am trying to learn Java by doing some (easy) ACM TCPC problems. The problem is finding number of overlapping times intervals. If there a one, a fight will happen between the two games connected to ...
2
votes
2answers
30 views

Encypt xml file with aes and storing on disk

Ok so i have written some code to encrypt xml and then store it on the disk. I want to be sure that the encryption code is secure so here is the code. ...
3
votes
2answers
55 views

Tic-Tac-Toe classes according to SOLID principles

I have these classes for my Tic-Tac-Toe game project. I am very new to object oriented analysis and design. Can anyone help determine if SOLID principles are preserved in this code or if it is ...
1
vote
1answer
36 views

Lambda to collect properties in a child object

I have a class: public class ProductInvoice { //Some other properties. private List<ProductEntry> productEntries = newArrayList(); //otherMethods } ...
0
votes
0answers
23 views

Two dimesional array in creating a multiple choice test [on hold]

I'm trying to create code that makes a multiple type test. I'm also trying to impress my prof by using a two-dimensional array (this hasn't been taught to us yet). I know there are some questions ...
7
votes
1answer
41 views

Printing three ASCII 'banners'

This code that I wrote for a lab works perfectly and gives the desired output. That said, it's over 200 lines of code to reach the result. This seems ridiculous, even when you consider that there is a ...
-4
votes
0answers
14 views

Tip exception:java.lang.NoSuchMethodError: main [on hold]

My exception: java.lang.NoSuchMethodError: main Exception in thread "main" My main syntax is correct. What else could be the problem? ...
4
votes
1answer
66 views

Checking digits in a number

I'm working on an exercise that counts the number of even digits, odd digits, or zeros in a user-input integer (I made it a long so the user could put in more ...
5
votes
2answers
50 views

Calculating numbers in the Collatz sequence

I have found two ways in which I can generate the Collatz sequence given a start number. I have looked briefly into their performance, but I'd like a more in depth/solid review into the difference in ...
2
votes
1answer
37 views

Rotation of a 2D array

I implemented the rotation of a 2D array in Java. The question is as follows. The first line will contain numbers m(number of rows), ...
8
votes
2answers
177 views

Iterating over Dungeon Map

I'm working on an RPG so of course I have to have some dungeons. I've got the dungeon generation working, with the output being a DungeonTileType[][]. Now I ...
-4
votes
0answers
27 views

Java calculator that keeps going [on hold]

New to Java and trying to write a calculator program that will input two numbers and an operator, do the calculation, then ask for another number and operator and continue to do that operation on the ...
3
votes
0answers
44 views

Initialize a hashmap in a more compact way without external libraries [migrated]

Is there a way to make this code more compact? With less lines without using libraries? I am using Java 7 ...
8
votes
2answers
378 views

Knight moves in Chess game

I am trying to learn Java by doing some (easy) ACM ICPC problems. The problem consist to check if the knight in a chess game can move from a point A(r1, c1) to ...
4
votes
2answers
167 views

Java Dice Roller

I've written a basic dice program in Java which takes a number of faces then randomly selects a number within that boundary. Here is the code: ...
0
votes
0answers
20 views

Using the same RecyclerView.Adapter with a different ViewHolder

I would use the same RecyclerView.Adapter with two or more different fragments. Every fragment uses a different view items layout so I must use a different ...
2
votes
1answer
26 views

Retrieving data from cursor associated with a list item inside an anonymous listener method declaration

I've run into a problem twice just recently. Though I'm getting around it I can't help but feel that it's a rather unconventional method and that there's a better one. This app is an exercise in ...
2
votes
2answers
62 views

Inversion count algorithm

I implemented the inversion count algorithm using the merge sort approach for this question. The question begins with a number t = number of test cases and then for each test case you input size of ...
2
votes
1answer
40 views

Iterate faster through the Android file system and find specific files using java multithreading

I'm trying to extract specific files and visualise them in a list/grid. For that purpose I'm starting a Service to do the background job, and when it finishes it fires an Intent which will be captured ...
2
votes
0answers
44 views

Brute force shortest path in Java

I had to ask myself a couple years ago: before Edsger Dijkstra invented his famous shortest path algorithm, how brute force approach would seem. Below is my version. It's super slow, but I find it ...
5
votes
5answers
627 views

Menu to save and load football team information

I am a newb, and whilst I'm sure my formatting can be improved, I really want to know, how I can re-use my code for this simple program. The objective is simple, football game with a menu, that allows ...
3
votes
1answer
42 views

Java Properties Wrapper

I've decided to make a wrapper class for the java.util.Properties class since, in its current state, it only allows for storing and reading ...
2
votes
1answer
43 views

Destroying a process if it takes too much time

I am executing a shell script from my Java program using Process and I want to kill/destroy that process if my script takes long time. I came up with this code and ...
4
votes
2answers
752 views

Funny String Java Solution

I'm a little rusty in Java, but I'm using it to get ready for interviews. Here's the problem description from HackerRank: Problem Statement Suppose you have a string \$S\$ which has length ...
-3
votes
0answers
18 views

Pong Code Java Applet [closed]

I wrote a very simple pong applet game. Right now, the ball basically is just bouncing off the sides, but I want the platform to move by using keylisetner, but it ...
1
vote
1answer
40 views

Java “pulse” between threads

I have two threads. One runs a simulation and one runs a UI. In the UI, it is possible to trigger a "tick" of the simulation. There are a few constraints: Ticks run on the simulation thread Each ...
3
votes
0answers
22 views

Swing Component Resizer Class

I've created a class to help resize Swing components while maintaining their aspect ratio within a container. The class works by creating an instance and adding a container's components to it, then ...
2
votes
3answers
67 views

Optional Consumer for ifNotPresent

As Optional have only ifPresent and not have another function to be run in false case so I did the below class for that, please check it and give me your feedback: ...
4
votes
2answers
67 views

Java Max-Stack implementation to return maximum value in the stack

I have written the below program to write a Java stack implementation. I have added a method which returns the maximum value in the stack, e.g, a pop. The implementation for this is based on the Max ...
1
vote
1answer
61 views

Routing Java objects using conditional consumers

As per a previous question here and answers I got, I used it to get a new implementation. I found that I have to make two implementations match once "to ignore other consumers after matching once" and ...
13
votes
1answer
226 views

Three in a row: Tic, Tac, Toe

The other day, I started thinking of a new personal project to start that I wanted to do in Java. As I started to do it, I realized that I was constantly deleting classes, creating new ones, merging ...
8
votes
5answers
193 views

Limit an integer to certain number of digits and suffix '+'

I am having a problem describing what the following code does. Below is my attempt at its javadoc. ...
3
votes
1answer
101 views

Reuse a base class [Activity] handler in all sub classes for background work

We are using the Thread of a common base class but using its handler in all its sub classes. The code is working fine but is it the right way to go about? Our base class looks like this: ...
10
votes
1answer
220 views

Find sum of K largest elements in an array

The problem statement is to write code that returns the sum of the K largest elements in a given array. The array is not sorted already. My solution is based on the idea of quicksort, by finding ...
3
votes
2answers
73 views

ConsumingRouter to consume based on condition

Started as to make a stream splitter to split stream based on condition, but finally found that I did ConsumingRouter, to consume based on condition and while have to provide consumers before using ...
6
votes
1answer
37 views

Exposing configuration elements to program

I have a config file stored in a java properties file: output_path=/some/path/somewhere num_threads=42 # ad infinitum I have an singleton enum which controls the ...
5
votes
1answer
71 views

Java InfiniteStream with Queue

I did InfiniteStream by implementing Stream and Consumer. You can initiate the stream then ...
-2
votes
0answers
22 views

Determining the area of a circle with class areaCircle [closed]

This seems to be throwing several errors. I am sure it is most likely a simple error since this is only the seventh or eighth program I have compiled, but I am unable to see where the error is. I was ...
5
votes
5answers
651 views

Car Savings Calculator

I've created a second 'calculator-like' program, this time using the JOptionPane rather than typing in the console. At the moment the code looks to have a lot of repetition so I'm looking to simplify ...
5
votes
1answer
89 views

Toast functions

I made this method for a better Toast function. But I have doubts about it because this Toast forced me to make two methods ...
10
votes
2answers
261 views

Unique value finder

For our first assignment in our algorithm class we are suppose to solve several different questions using information from a 2D array. We are also suppose to optimize our code to get more marks on our ...
1
vote
1answer
43 views

Key Value Store for Android on top of Sqlite3

I wrote this simple key-value interface on top of Sqlite3 to use in my Android app. I am using this to persist Java objects as strings converted using Gson. The public API has 3 methods. ...
10
votes
1answer
88 views

Roman Numerals in Java

I wrote a class that can convert to and fro from Roman Numerals and Decimals. I would appreciate critical points on everything, especially: Shortening my code. Choosing a better approach. Using ...
1
vote
0answers
15 views

Counting Bloom filter library in Java - follow-up

This question is the second iteration of Counting Bloom filter library in Java. I did nothing more but fixing the remove method in order to fix an issue mentioned ...