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)

1
vote
0answers
16 views

Using the Template Design Pattern to reduce code duplication between two algorithms

I have made a Skyline query solver which for now can solve the query with two different algorithms. The first is Block-nested loop (BNL) and the second is Sort filter skyline (SFS). The two are ...
3
votes
2answers
111 views

“Ella” Java chatbot

I recently developed an interest in AI and thought I would develop this little chat bot. Are there any recommendations/modifications? ...
-1
votes
0answers
13 views

Refactor chain message [on hold]

I get the response object from other project library class which I cannot modified. How should I refactor this code so that I don't have to check for NullPointerException, ArrayOutOfBoundException or ...
3
votes
0answers
29 views

TrackDAO: what can be improved?

In this specific situation there is a table with trackdata and a form to add rows. For the sake of clarity I won't include the view-related code here. The added rows are added to a LinkedList when ...
1
vote
1answer
42 views

Form a loop with previous and next

I have a class Edge which looks something like this: class Edge { Edge previous; Edge Next; } I have edges in an ...
2
votes
2answers
59 views

First Linked List in Java

I just started learning Java, and wrote up a linked list. I'm coming from just having learned Haskell, so I've been out of the mindset of stateful computations for awhile. I'd like to know how it ...
4
votes
1answer
55 views

Animals in the Zoo

I am creating a zoo. In my zoo I want to have 3 types of animal: Mammal, Bird and Fish. I ...
1
vote
1answer
48 views

Point2D.Double wrapper

I have made a Point2D.Double wrapper so I can add my own functionality (like a dominate method) and alter some (like ...
0
votes
0answers
21 views

Simple guestbook made using Java EE 7 technologies (JSF, CDI, EJB, JPA)

I'm making my first steps in Java EE. This is a simple guestbook made using Java EE 7 technologies (JSF, CDI, EJB, JPA). I will really appreciate your feedback. Does the code follows the standard ...
9
votes
2answers
600 views

TopCoder problem “Lottery” - SRM 144 (Division I Level Two)

The problem statement Summary: The rules of a lottery are defined by two integers (choices and blanks) and two boolean variables (sorted and unique). choices represents the highest valid number ...
3
votes
2answers
185 views

Game of Life Neighbour count optimization

This is a working Neighbours method. Is there any way to make this simpler and concise? ...
5
votes
6answers
483 views

Displaying a letter grade based on a percentage

Here is a class I made that is able to ask a teacher what percentage their student has in a class and gives them back a grade. The code is very repetitive and I am wondering what I can do to simplify ...
2
votes
1answer
76 views

Game of Life with exceptional Neighbours

As it currently stands the code works fine. Is there a way to optimize the code in the class Neighbours? What I have done was to copy the code for each of the ...
0
votes
1answer
74 views

Class for finding the median of a two-dimensional space

I have a simple static class that it's purpose is given an RDD of Point to find the median of each dimension and return that as a new ...
0
votes
2answers
45 views

Is this implementation of doubly linked list correct?

I am trying to follow the template provided here to create a doubly linked list in java. This homework is based on this lecture. Can someone please review my implementation? No change to this part of ...
7
votes
4answers
661 views

Entering two integers and returning a decimal fraction

After a couple of small programs in Python we are now asked to do some basic stuff in Java. I don't really know where to start to improve this and whether it's even necessary. This is an exercise, so ...
0
votes
0answers
18 views

Issue with Address book program [on hold]

My professor gave us this source code as a template for a project and there are errors when BinarySearchTee is called. I'm not entirely sure as to why this is? ...
0
votes
0answers
27 views

Converting a wrapper object to a value object

I have ChannelWrapper and Channel Value Object. I want to convert each and every field of ChannelWrapper to Channel Value ...
-3
votes
0answers
14 views

Recommended DAO package structure [on hold]

When creating a package structure for DAO in spring/hibernate project, what is the recommended approach? Should Interface and Implementing class be on same package or different package? Or What will ...
0
votes
1answer
43 views

Nearest point using 2D tree, static variable for the closest point so far

This is a problem from a Coursera class: Write a data type to represent a set of points in the unit square (all points have x- and y-coordinates between 0 and 1) using a 2D tree to support ...
1
vote
1answer
51 views

Drawing sets of boxes to display contents of arrays

This code draws two sets of 9 boxes on the screen to display the contents of two arrays. How can I speed up, shorten and make the code more efficient? ...
2
votes
1answer
54 views

Loading the JDBC driver jar dynamically from external location

I have a small project in which I get the URL, username, password, and driver from a text file and I have to fire a query on the database by dynamically reading the jar file in a predefined directory, ...
-1
votes
0answers
21 views

how to perform calculations using stacks Java [on hold]

Hello everyone I have to do a java calculator using stacks and when i try to do the calculations it does not work. Example if my stack contains 5 and the user enters -2 stack should change to 3. Here ...
0
votes
2answers
31 views

Including references in onResume Lifecycle

What's a more concise way to do this? It's way too verbose for my taste. ...
4
votes
1answer
58 views

School which registers students by preferred courses

The point of the application is to create a school, create courses for that school, create students and register them to the school, assigning them courses based off the courses they prefer. There ...
3
votes
1answer
67 views

Removing duplicates from unsorted LinkedList

Removing Duplicates: ...
1
vote
2answers
76 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
15 views

Passing data from domain to UI in Java [closed]

How do you pass data to paintComponent(Graphcs g) without using a direct reference to your domain in your view logic? ...
2
votes
1answer
40 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: ...
2
votes
1answer
44 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
69 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
1answer
81 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
58 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
49 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
44 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
27 views

Spring MVC OneToOne mapping is not working [closed]

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

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

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
231 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
284 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
2answers
60 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
29 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
72 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
7answers
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
33 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
28 views
5
votes
2answers
86 views

Overloading email sender utility class 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 ...
5
votes
4answers
296 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
57 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 ...