Tagged Questions

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
1answer
17 views
1
vote
1answer
33 views

Simple deck of cards

I had recently completed one programming challenge where I've had to design a deck of cards. The time was limited but I tried my best. I designed the basic operations and am wondering if I can improve ...
0
votes
0answers
11 views

Passing data from domain to UI in Java [on hold]

How do you pass data to paintComponent(Graphcs g) without using a direct reference to your domain in your view logic? ...
2
votes
1answer
32 views

Score Validation

Was just wondering if I was using nested if statements to much. I've been looking around and it seems that people try to not use them. Also does the code look messy in any way? Anyways here it is: ...
0
votes
1answer
26 views

File input and sorting averages with movies

So far I have Java code that will: take in two .csv files store each line as a string in a string array split it into a 2D string array where a comma would act as the separator sum the number found ...
1
vote
1answer
59 views

Save parameters in a “key: value” format

I have been playing with Java for around a year and I started writing this API for storing data in files. I wrote this method which will save the parameters in a "key: value" format in a file. The ...
1
vote
0answers
41 views

OOP bank database

I have been working on this: Design a class for a bank database. The database should support the following operations: ❍ deposit a certain amount into an account ❍ withdraw a certain ...
0
votes
2answers
42 views

Displaying a city name with concatenations

I am learning MVC and Android. I have create a sample program which is supposed to implement the MVC philosophy. I plan to build my codes on top of this. I wish to know whether I have got the concept ...
1
vote
1answer
45 views

Flattening a HashMap of (String → ArrayList) to an ArrayList

I have one HashMap<String, ArrayList<String>> and I want to concatenate a key with every item in its ArrayList. ...
3
votes
1answer
36 views

StreamIterable - create an iterable from a Java 8 Stream

This seems like an easy thing to mess up, so I'd be grateful if you could think of any edge-cases that I've missed. ...
0
votes
0answers
23 views

Spring MVC OneToOne mapping is not working [on hold]

Query: How to validate OneToOne object in the Spring MVC? i.e. return an error to the JSP page from Spring MVC BindingResult if OneToOne mapped object is inputted null? In the following class, if ...
-3
votes
0answers
15 views

Error at JOptionPane row and outFile.println row (61 and 63) [on hold]

I have this project and I'm stuck at the end...row 61, 63 have errors. Can somebody help me? Thank you Create a Java Project to be named PayRollProject using NetBeans IDE that allows the end user ...
5
votes
3answers
222 views

Close Scanner if no input

I'm in very early stages of learning some Java coding. I'm asking for this review because, although the code below works, I'd like to know if it's an ugly way of achieving it. What I want the code to ...
5
votes
2answers
271 views

Quiz Evaluation

I have written a code for following problem: Write a program to grade a short multiple-choice quiz. The correct answers for the quiz are: C 5. B A 6. C B 7. C D 8. A ...
1
vote
1answer
45 views

Factory object with a dependency on a bean

My problem is quite straightforward. I want to build a factory, but the kind of object returned depends on a value read from a bean that is somehow a cache. So of course, I can't call the bean's ...
1
vote
1answer
23 views

Web Service implementation on the client

I will be creating a web service as part of a group project for university, which will be developed using Java within the Eclipse IDE. Having no prior experience using web services, I managed to ...
1
vote
2answers
61 views

Bank simulation using ArrayList

Problem Statement: Design a BALANCE class with account number, balance and date of last updation. Consider a TRANSACTION class with account number, date of transaction, amount and transaction ...
13
votes
6answers
1k views

Determining whether two scrambled strings are equivalent

I was able to complete the problem doing it in this manner, but I would assume there has to be an easier way. Sample input: abc, cba Output: ...
1
vote
1answer
32 views

Getting recent stations

I made a database for my Android app using SQLite and it works fine. However, as I understood, SQLite calls shouldn't be made on UI thread. Is the below okay or not? ...
-2
votes
0answers
27 views
5
votes
2answers
79 views

Overloading methods take single or array arguments

I'm writing a simple utility class for sending an email. I'm not sure what's the proper way to present this to a consumer. Should I force them to use an array in the send method? Or should I provide ...
5
votes
4answers
286 views

Java Stream Exception Handling

I find this piece of Java code really ugly and cumbersome. How can I refactor it to be more clean and easier to read? ...
3
votes
1answer
53 views

JavaCC Android port User Interface (Activity) class

I have been working on a port of JavaCC for Android. It is mainly an interface. I needed only to modify the original source to redirect output to a TextView. The point of this project is to rekindle ...
0
votes
0answers
19 views

Im having trouble creating this yahtzee game in java [on hold]

Basically i have to create the yahtzee game with the methods like 4 of kind 3 of kind, small straight, large straight, etc. Im having trouble figuring out a way to check if the dice rolled fit in any ...
8
votes
2answers
250 views

Making a text-based RPG game

I started making a text-based RPG game and before I spend a lot of time on it, I wanted to know if there is a better way to make it. Currently I'm using switches to flow through the game, I also know ...
-1
votes
0answers
33 views

Reflection of an object in a 3D world

The following is a excerpt from a class that is supposed to represent a reflection of an object in a 3D world, like in a mirror. After I started I discovered that mirroring is a property of an ...
0
votes
1answer
62 views

Streamlining a method to run faster

Update: I did some guesswork tweaking and let the heap reach a maximum of ~450 Megabytes (was originally using invokeAll). The program just finished in 6.3 minutes. I've been advised to use ctrl + ...
-2
votes
0answers
10 views

assignment types [on hold]

Is there any problem in assigning Integer to int? int x= Integer.class.cast(parameters.get("PO_PAGE_CNT")); As Integer is the parent class and int is the ...
5
votes
3answers
497 views

I command thee: do SOMETHING

I am currenly contributing to a Chat-Bot to be used across the whole SE-Network's chat which is implemented in Java 8. This bot is supposed to have commands. These commands again are supposed to be ...
-1
votes
1answer
45 views
1
vote
2answers
30 views

Codility AbsDistinct: Why is this solution not O(n)?

This is part of a series of algorithmic lessons and tests by Codility. For copyright reasons, I cannot reproduce the question, which asks to compute the number of distinct absolute values in a given ...
1
vote
1answer
28 views

Using composition or inheritance to enhance this linked list

Problem Statement: A method called insertEnd() exists, but it runs in linear time, because every time it is called, it walks down the list to find the end. Without changing the meaning of this ...
7
votes
1answer
57 views

Karp-Rabin with bitwise hash

As a Rags-to-Riches re-implementation of the Karp-Rabin question here, from @tsleyson, I thought it would be interesting to understand the algorithm better, and to use bitwise-shifting instead of ...
0
votes
0answers
27 views

Enhancement to Trezor library for Android

I'm only asking because I'm new and don't know enough to have a concrete question. Did I do this correctly? I worked on this until the code performed as expected, but I don't think I'm done. In ...
1
vote
1answer
60 views

Reading columns of a delimited text file

This class reads a delimited text file into String arrays on demand. Delimiter can be any regex. Features include: Read a single column Read a range of columns Read arbitrary columns by providing ...
5
votes
3answers
67 views

Karp-Rabin String Matching, Part 2

Part 1 is here. I wrote a Java implementation of the Karp-Rabin semi-numerical string matching algorithm. I incorporated the suggestions of @fge and @maaartinus from the other question into my new ...
0
votes
1answer
35 views
-2
votes
0answers
30 views
-1
votes
0answers
16 views

I can't seem to get my hangman java program working [closed]

'm trying to make a hangman program and I have no errors but the program will just terminate when I run it. Do you see any issues with my code? Can I add StringBuilder to strings that change in my ...
1
vote
1answer
25 views

A Java class for reading MaCH dosage files v2.0

Version 2 of A Java class for reading MaCH dosage files ...
3
votes
1answer
46 views

Implementing equals(), hashCode(), toString() in the hierarchy like the Optional<?> from Guava

I have simple hierarchy which looks [a little bit] like the Optional<?> from Guava: ...
0
votes
0answers
20 views

finding points of intersection not consistant [closed]

I have unfinished code to find the points of intersection of all lines that are perpendicular. So far I have this: ...
0
votes
0answers
24 views

Refactor switch statement using Strategy pattern or enum [closed]

I am refactoring an existing code which has a huge switch statement with more than 20 cases. I was thinking of using the strategy pattern, however this means I need to create 1 interface with 20 plus ...
0
votes
0answers
15 views

A Java class for reading MaCH dosage files v2

Version 2 of A Java class for reading MaCH dosage files ...
2
votes
1answer
63 views

ArrayList for Shop implementatin

Problem statement: Design a system for the following scenario: An item list contains item code, name, rate, and quantity for several items. Whenever a new item is added in the list ...
3
votes
1answer
51 views

A Java class for reading MaCH dosage files

A dosage file (used in computational genetics) is formatted like this: ...
1
vote
1answer
30 views

A Java class for calculating size of iterable/array v2

Version 2 of A Java class for calculating size of iterable/array ...
3
votes
1answer
46 views

A Java class for calculating size of iterable/array

Another exercise of Java generics: ...
2
votes
5answers
154 views

A Java class that prints a matrix

I am trying to learn some generic programming with Java: ...