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.
3
votes
1answer
12 views
Threadsafe HashMap with snapshot support
The problem
ConcurrentHashMap provides very weak consistency guarantees w.r.t iteration:
guaranteed to traverse elements as they existed upon construction
exactly once, and may (but are not ...
0
votes
0answers
11 views
Doubly circular linked list implementation with successive update in O(1)
For the queries mentioned in link in 3 parts, the first two parts have been addressed, as mentioned below:
Part I (6 points)
list/DList.java contains a skeleton of a doubly-linked list class. Fill ...
3
votes
1answer
64 views
Automagic (or not quite so) Domain Model Class Validation
The Task
I was assigned a small task, concerning validation of Domain-Model classes.
The Validation for a String property of one of our Models was required to be unique across the whole Table. And ...
0
votes
0answers
18 views
overriding Iterator<> [on hold]
I'm having trouble understanding the idea of overriding and interfaces. First of all, this is hw and I'm only asking for guidance.
I am given the following interface with some methods to implement
...
1
vote
0answers
16 views
Factors of a number [on hold]
For practice in my programming class I tried to do a problem from the book but I am having a little trouble. The book told me to create a program that shows the factors of a number you would input. I ...
0
votes
0answers
27 views
“Guess a number b/w 1 and 100” game [on hold]
So for my AP CS class, we were to make a guessing game, where the user has to guess a number between 1 and 100. I've already got that part down. The teacher also wanted us to add extra stuff, like ...
2
votes
0answers
22 views
AsyncTask and IntentService
I was disappointed using GCM, so I'll use long polling for crucial parts. Following my approach:
...
2
votes
3answers
41 views
WeatherForecastRequest and its builder
WeatherForecastRequest is only simple HTTP parameters wrapper. It is using to get forecast from the openweathermap.
At first ...
3
votes
2answers
36 views
Making a database entity superclass
I am using JPA for my database work and I need to create a database entity superclass which all of my table entities will extend.
Every database entity will have a primary key named ...
0
votes
1answer
41 views
Mapping interface between POJOs and DTOs
Following up on this question DTO interfaces for implementing web service integration I came up with this implementation.
Data Transfer Object interface following a java.util.Map protocol. The ...
-1
votes
0answers
17 views
CodeEval: Detect Cycles is partially correct? [on hold]
I am attempting Code eval's problem of Detecting Cycles, but all I get is that it is partially correct. I am not sure what is wrong with
...
4
votes
2answers
124 views
Merge Sort an integer array
I've implemented merge sort an integer array. Is it okay to use i,j,k as variable name for looping? Should I change them to more meaningful names? Overall, any further suggestions on this code?
...
4
votes
3answers
112 views
Dollar value of coins and calculating interest compounded annually
I've made this program to do a few integer calculations. Do the methods for converting the numbers look good? Do you have any other basic tips?
...
1
vote
1answer
49 views
Create a complete binary tree
Write a program to create a complete binary tree, which includes an addItem method such that an individual element can be inserted into the tree to maintain the ...
-4
votes
0answers
41 views
Rewrite Python code in Java [on hold]
I need help for rewriting Python code into Java. Unfortunately I know how to write Java programs but I don't have any experience with Python.
...
0
votes
2answers
65 views
How to write unit test cases for any real time Java app? [on hold]
With lack of real time experience in developing a Java application, I would like to understand the testing strategy for any written module made of multiple classes. Below is the sample application ...
0
votes
0answers
38 views
Functional interface uses uncheck or unsafe operations
First of all, I am absolutely surprised that this code even works. Originally what I did was create a version checking system for Minecraft plugins (specifically Bukkit, Craftbukkit, & Spigot).
...
3
votes
1answer
69 views
DTO interfaces for implementing web service integration
I am trying to define some interfaces to implement some web service integration middleware.
The SOA pattern that fits this system is probably the Multi-Channel Endpoint.
I expect a lot of mapping of ...
7
votes
3answers
57 views
Parsing dates from an OCR application
I wrote this code to parse dates from the output of the OCR, which means that the obtained date can be literally anything, so I put some restrictions in place:
Date is the the format of: ...
-2
votes
0answers
20 views
Refactoring duplicated method [on hold]
I was wondering how I could refactor this duplicate code. The only difference
in the methods are a = goToTheStoreForFood(); and ...
3
votes
1answer
19 views
Generic Timing Class - Follow Up
I wrote a class which can time and compare functions.
I already posted it here once before, and got great suggestions from @rolfl, which I have added to my code.
my original question can be found ...
0
votes
0answers
24 views
Class template specialization for empty template parameter
I'm implementing classes for simulating and generating different kind of automata. I'd prefer to use the same State and Transition classes for all the automata: NFA, DFA, PDA, etc.
For a PDA a ...
0
votes
4answers
1k views
Program that prints out repetitions of 3 and 5
This works in my Eclipse, but I think there is a better way to do it.
...
1
vote
1answer
30 views
Multithreading synchronization between reading and writing in a channel
I was hoping to get some feedback on what the recommended design pattern are for this subject.
...
3
votes
4answers
96 views
String switch statement
I'm working on code for an assignment and I was hoping you all could point me in the right direction.
Basically I had to write a program that will issue out a multiple choice test. I have 4 options, ...
5
votes
2answers
42 views
Insert sort not working for large arrays
I've written an insert sort and for my assignment I must be able to sort an array of size 107. I've tested this sort with smaller arrays and it always sorts it correctly (up to size 105). If I make ...
4
votes
1answer
79 views
Dependency Injection into an Abstract Class
Me and another developer have recently forked and taken over an abandoned, open-source project. I have also been reading articles and watching videos by Misko Hevery.
When I was reading through the ...
11
votes
4answers
759 views
Hangman game in Java - second try
Please look over my new object-oriented version of my Hangman game I posted here about two weeks ago.
I know I should work more on commenting and be clearer and more descriptive of the methods and ...
8
votes
4answers
110 views
Align Strings for Output
I wrote a class which can format input so that it is properly aligned.
I'm interested in all suggestions (regarding structure, usability, style, naming, comments, etc).
I'm especially wondering ...
26
votes
5answers
2k views
4
votes
1answer
48 views
Check if downloading image from Internet is already started and if isn't then start downloading and set flag “downloading started”
In the method getView() in my implementation of ArrayAdapter I have to download image from Internet using the image's url and ...
1
vote
1answer
32 views
Spring Service Method Logic
I am learning spring and am wondering about this service class's method. Is there a way to split this method up? Is there a way to use spring framework to make this method more readable? Should I move ...
15
votes
3answers
2k views
Beastly if statement, adding a course to one of 8 periods
I have this rather ghastly if statement and I'm sure there is a way to condense it, but I don't really know how. I was told a ...
6
votes
4answers
486 views
Raising a number to an integral power
I'm currently learning Java along with the Stanford online "Programming Methodology" course and, while it is awesome, I do lack any kind of human feedback.
This exercise was to create a method that ...
7
votes
3answers
188 views
The 100 game - CanIWin()
Problem:
Two players pick numbers from a common pool of number to reach a combined total.
The player who get to reach/cross the target value wins.
The problem is to find out if player-1 can ...
4
votes
2answers
70 views
4
votes
1answer
39 views
Generic Timing Class
I have written a class which can time functions, and I'd like to have it reviewed. I'm interested in everything (better naming and commenting, accuracy of measurement, usability, structure, use of ...
4
votes
4answers
319 views
Array Implementation of Queue
I've implemented the queue data structures using array in java. Anything I need to change in my code?
Queue.java
...
1
vote
0answers
35 views
Multi Threaded Report Generation
I have a requirement where i have to generate some report basically read from db and write data to Excel.
I want your help in reviewing following things in my code.
Data Base Connection
Multi ...
0
votes
1answer
18 views
Showing a JDialog whenever there is an exception
I have made a method which I use to show the exception error through a JDialog window whenever there is one in my program.
For now I can pass it either a String or ...
-3
votes
0answers
23 views
java program using for loop [closed]
i am new user at java application and i want to get an out-put such as given below,so please any body can hep me that how to get required output using "for loop" in java?
i shall be very thankful.
...
0
votes
1answer
31 views
First facelets with JPA app on glassfish
So far as I've tested it, these few facelets files with JPA database connections work as intended. The queue, MyQueue, is at ...
2
votes
0answers
22 views
Logging using function as decorator in Guava
I needed to add a logger into my flow based on FluentIterable from the Guava library. I have a lot of functions and in some cases I would like to add logging when ...
1
vote
1answer
26 views
Optimizing code using semaphore to control Netty channel pool - Part 2
Please have a look at my original question:
Optimizing code using semaphore to control Netty channel pool
I have made some changes as pointed out by @rolfl
The new code is as follows. Is this ...
2
votes
3answers
96 views
4
votes
1answer
60 views
Simple Cellular Automata (think Conway's Game of Life) simulator
Firstly, let me say that this code works, as posted. It fills a 10x10 grid with a random color (black/white) then runs a cellular automata simulation on the grid, starting or pausing when the button ...
2
votes
1answer
65 views
Best way to write generic factory in Java
I need to write a factory of generic converters to produce converters from/to MongoDB objects to/from Java objects. Here is my implementation, it doesn't look good enough to me, so I would like to see ...
8
votes
6answers
2k views
4
votes
4answers
374 views
Array Implementation of Stack
I've implemented the basic logic of a stack data structure. How can I make this code more generic? Is there any better way to display the stack contents?
StackMethods.java
...
1
vote
3answers
76 views
A Java Web App with Servlets, JSP and Session: shopping cart example
This is the only Servlet I have:
...