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 (1)

2
votes
2answers
43 views

Making sure user inputs correct type

I have two functions that are used to prompt and recieve input from the user. One is for int and the other is for boolean. They ...
1
vote
0answers
9 views

Intended to return account address using account ID, which uses Spring Stored Procedure class

I have not used Springs stored procedure class before to return data and I was hoping someone would be able to check this for me.. If it will A. Return data, B. Can be improved. C. If I wanted to ...
0
votes
0answers
9 views

Avoiding IllegalStateException in MVP when view is not ready yet [migrated]

In an effort to improve my coding skills I am trying to make use of the MVP pattern in one of my first Android applications. It is going well but I have hit one issue that I am not sure what is the ...
1
vote
2answers
30 views

Calculating the Nth number in the supertable of two numbers

Below is the problem: Little Timmy is exceptionally good at math tables, so his teacher decided to make things a bit more interesting. His teacher gave him two numbers, A and B, and told him to ...
12
votes
5answers
1k views

Find min of 3 numbers hardcoded

...
-3
votes
0answers
13 views

smbfileinputstream(retrieving a file using android) [on hold]

I use the code below to copy a file from a remote pc to my android device the file was created in my device but the file content was not copied. ...
8
votes
2answers
72 views

Finding the next number in sequence

I have a question to find the N th number in the sequence. 1 11 21 1211 111221 312211 13112221 1113213211 The next ...
2
votes
4answers
72 views

Java sort by selection: which is better in regards to readability and efficiency?

Which algorithm do you think is better in regards to readability and efficiency? selection(): ...
-3
votes
2answers
59 views

static factory method alternative to nested switch statements? [on hold]

At first I liked the idea of nested switch statements, but on a second-look, it seems a bit confusing to read. I'm iterating through two enum's as so: ...
4
votes
3answers
48 views

EmailSession in Java Webapp

I have written an EmailSession class to connect and get (unread) mail messages. It is all working, but I would like to see your opinions on any enhancements or ...
1
vote
1answer
43 views

Insertion sorting an int array

I'd like to improve this Insertion sort code ...
5
votes
4answers
121 views

Add-to-cart method has too many conditions

I have a method that seems to be too much for one method. I might be validating programming methodology. I just don't know what to do with it. Would a switch statement be better? Should I break it up ...
2
votes
1answer
22 views
7
votes
5answers
374 views

Checking if an array is sorted

I've come up with two ways to check to see if array is sorted and return true if it is. ...
12
votes
3answers
556 views

Implement “Upgrades” Feature for Game

I am building a simple adventure game that has "upgrades" feature. In this game, user controls one player, that can be upgraded to increase things such as: Amount of gold earned Maximum health ...
0
votes
0answers
12 views

Using ArrayList instead of an array to avoid using a normal for loop [migrated]

I'm reviewing a piece of code that looks like this: ...
3
votes
2answers
71 views

Is this too much work for 1 listener?

Is this too much work for 1 touch listener? Is this bad for devices with slow CPU's? ...
9
votes
2answers
165 views

Music & DJ IRC bot

I wrote an IRC bot in Java using Pircbot for use in twitch(.tv) chat. It is intended to be run locally and to only be connected to one channel at a time. When it is connected to my channel, it will ...
-1
votes
0answers
39 views

OO Design - returning a result vs. returning an object already including the new result [on hold]

I hope this question will not be downvoted. I am interested in a good OO design but unfortunately do not have any well experienced developer who can answer me. I'm creating some mechanism for ...
5
votes
2answers
200 views

Strategy pattern instances based on enums

I have a view which takes a DataPresenterStrategy instance to retrieve the proper text out of some data: ...
4
votes
1answer
37 views

Potential quicksort optimizations

I implemented qsort() like this. I was wondering what improvements I could do to make it better. ...
0
votes
1answer
30 views

Delete nodes in linkedlist whose next node is greater

Given a singly linked list, remove all the nodes which have a greater value on right side. Examples: a) The list 12->15->10->11->5->6->2->3->NULL should be changed to ...
4
votes
4answers
221 views

BitShift code compacting

I'm new to Java programming and am really enjoying it. I made a bitshift program, but I think it's too long. I expect the program to: Let users input the number and degree to be shifted Specify if ...
1
vote
2answers
42 views

Check if all leaves are at same level

Check if all leaves are at same level. This question is attributed to geek for geeks. Looking for code-review, optimization and best practices. ...
1
vote
1answer
30 views

Find union and intersection of linked list

Find the union and intersection of linked list, given that elements don't repeat in a single linked list. This question is attributed to GeeksForGeeks. Looking for code-review, optimizations ...
9
votes
2answers
145 views

ISBN missing number solver

This is a programming contest question. Question as follows Problem Definition An ISBN (International Standard Book Number) is a ten digit code that uniquely identifies a book. The first 9 ...
7
votes
3answers
97 views

Very Basic Java Piano

I've been reading "Head First Java" and some of the early projects surround basic swing and basic MIDI. So I've put the two together and written a basic "Synthesiser"/"Piano" using what I have ...
0
votes
0answers
22 views

Convert a doubly linked list into balanced binary search tree in-place

Given a doubly linked list which has data members sorted in ascending order, construct a balanced binary search tree which has same data members as the given doubly linked list. The tree must ...
6
votes
1answer
35 views

Detecting Two Intercepting Circles with editable x, y, and radius in JavaFX

I was actually pretty proud of this, was a programming project that I came across in this book I'm working through. I only really had problems on figuring out the formula for detecting whether the two ...
-1
votes
0answers
15 views

export data to excel but I am getting Java out of memory message in excel [on hold]

Hello all I have a new issue with this program. I have removed the autoSizeColumn and it reaches the point to where it is about to write to the excel workbooks. I am now getting a ...
1
vote
1answer
45 views

Java service layer code cleanup

I have the block of code from my project service layer and I'm not happy with it. It seems overly complex and I would hate to have to calculate the cyclomatic complexity. This block is called in ...
0
votes
2answers
47 views

Selection sorting an int array

I'd like to improve this selection sort code ...
2
votes
1answer
45 views

Refactoring Android fragments

I have an Android app that shows some fragments, but I'm repeating lots of code. MainActivity.java ...
7
votes
2answers
86 views

Algorithm to calculate semi perfect integers, lack of effeciency

I'm working on an algorithm to calculate weird numbers, and to do so there are several properties that needs to be calculated, one of them being, if it is NOT a semi-perfect/pseudoperfect number. My ...
3
votes
1answer
54 views

Implementation of MVC pattern with paintComponent method

Could someone review my code, with respect to OOP, clean code and MVC pattern? Main app: ...
4
votes
1answer
43 views

A Quadtree implementation with Colliders

I have created a QuadTree in Java and would like a general code review or suggestions. ...
-1
votes
0answers
12 views

infix to postfix and infix to prefix: not ordering correctly [on hold]

when I type in a+b+c for an infix expression, I receive abc++ as my postfix expression and ...
1
vote
2answers
52 views

SynchronizedArrayList implemented using reader writer synchronization

I am trying to understand the workings of reader writer locks. For the sake of learning, I implemented reader writer synchronization by my own. I implemented ...
2
votes
0answers
25 views

Loader animation using Custom View in Android

I created a loader animation for an Android app: a simple 3 dots loader. Is this the correct way to animate by using TimerTask? ...
0
votes
0answers
7 views

Rounding to one decimal place [migrated]

I im currently working on a temprature converter app. Everything works but I can get over 5 decimals and I have tried to look it up and search on Google but can't find out how do it. Here is where I ...
6
votes
3answers
687 views

Bubble sorting an int array

I'd like to improve this bubble sort code ...
7
votes
1answer
115 views

Binary search an integer array

I'd like this code to be improved ...
2
votes
1answer
58 views

Structuring Class Objects And Defining The Variables

I am trying to create an outline of what a character is in a game. Then I want to create 10 different characters and compare their stats at different levels. I am creating an interface called ...
0
votes
0answers
21 views

Swing client rests on Netty for I/O — how do I send/receive from the GUI? [migrated]

For right now, the client instantiates the Swing GUI. This seems to work, to a degree. What's the correct flow to allow messages to get passed to, and received from, the GUI? client code: ...
8
votes
2answers
60 views

Contest code for a maze problem

I would like to ask your comments on my contest code for the following problem: We're going to have a slightly more logical puzzle today. We're going to write a program that will find a path through ...
4
votes
2answers
91 views

“Sherlock and queries” challenge

I'm writing some Java code for some pretty large datasets, in a puzzle I'm trying to solve. The output is correct, but the program doesn't run within the time limit for all the test cases. I've ...
8
votes
1answer
78 views

Object pool implementation

Below is my implementation of a pool. It is based on a hash table and supports using strong, soft or weak references to store objects. At the start there is a builder class to configure and create ...
1
vote
0answers
34 views

Why is it suggested to replace Temp with Query? [closed]

To refactor the code, it is suggested here to replace Temp with Query, for example in following code, basePrice should be extracted to a method. I am wondering why is it a good practice? If I keep the ...
3
votes
2answers
32 views

More efficient way to draw bufferedimage into another

For what I'm doing, I need to be able to draw a buffered image directly into a larger buffered image. I've searched around a little and still have failed to find a better way, but my current way is ...