Java is a high-level, platform-independent, object-oriented programming language originally developed by Sun Microsystems. Java is currently owned by Oracle, which purchased Sun in 2010.

learn more… | top users | synonyms

2
votes
1answer
19 views

Best practice for allowing mutation of a Collection type field

Suppose I have a (DTO style) class with a field that is a list: public class MyClass { private List<String> stuff = new LinkedList<>(); } There are a few choices to allow mutation ...
0
votes
0answers
10 views

Stored arraylist collection and adding to front

I'm working on running some methods like adding elements to back etc. using stored ArrayList collection. But unfortunately the main problem is adding to the front is not supported by stored ...
0
votes
0answers
27 views

Personalization of code: Personalized debugging message, personalized strings and project tags

I was given a code review today by a coworker. 1) I'm told not to use personalized tags to aid in searching for important portions of the code. For example: Personalized Strings, for example ...
6
votes
3answers
298 views

Unit Testing Competition

My employers runs a monthly unit testing day competition. One entire day is dedicated to writing unit tests -- obviously we do more testing throughout the month, but this is an entire day -- and the ...
7
votes
8answers
1k views

What stops C from being compiled/interpreted/JIT'ed? [on hold]

Java is often praised for its amazing portability, which I presume is because of the JVM. My question is what stops C from being being compiled/interpreted/JIT'ed.., if so, C can also be write once ...
0
votes
2answers
97 views

Is there a hashCode()-like method that can be used for state checking?

I thought up a simple and efficient way to combine states with events to make event handling more efficient. My idea of state checking involves State objects that hold reference to mutable variables ...
-9
votes
0answers
56 views

How would you code this in Java? [on hold]

There is a long hallway leading into a factory with 1000 ceiling lights hanging from the ceiling with pull chains that turn the lights on or off. You have a line of 1000 workers waiting to get into ...
1
vote
2answers
98 views

distinguish requests from the same vehicle

I am implementing an small app to track buses based on Crowdsorcing. The riders send data long, lat, mac, route to the server as JSON string. In my database I have table bus to insert the transmitted ...
1
vote
0answers
31 views

Method documents differs between Java docs and Android docs

Some times I see problematic differences between Java doc and Android doc in about method documents.For example in about setReadable (boolean readable, boolean ownerOnly) method you can see java doc ...
-2
votes
0answers
42 views

Algorithms for edge detection in digital photos? (Java) [on hold]

So far I've found that one method of edge detection in photos is to calculate the difference in the RGB signature from adjacent pixels and whether that difference crosses a certain threshold or not ...
1
vote
3answers
90 views

Database view performance - good practice?

Often times at work we opt to create views in the database to expose the data that we want to work with instead of building some monster query in our code. Being somewhat new to this field my ...
1
vote
1answer
42 views

Testing strategy for wrapper class

In my Android project I decided to create wrapper around SharedPreferences(which is basically key-value storage) with following interface interface Preferences{ public void saveInt(int value, ...
2
votes
1answer
211 views

Class becoming God Object what pattern to use

I am developing Android app and my MainActivity is becoming God Object. By the way native Activity class implementation is some sort of God Object already. The problem is that my activity class is ...
0
votes
0answers
52 views

The best shard key for user authentication

For access to my API user should send login and password and get generated token for access. Account login password Suppose the size of account's table is very large. So large - so needs ...
0
votes
0answers
186 views

Is there a more efficient way to write this method? Java [migrated]

I'm trying to write a program that creates music. I am using the JMusic API to accomplish this. These are the following constants defined in JMusic that I'm using: WHOLE_NOTE = 4.0 HALF_NOTE = 2.0 ...
0
votes
2answers
130 views

Name of data structure that's tree-like with multiple root nodes

I'm attempting to implement a data structure, and using a more traditional tree data structure, but I'm not using the root node as it holds no real value in the context I'm using it in. Ideally, I ...
0
votes
2answers
66 views

What is the algorithmic time complexity of this program?

I wrote a simple program in java to create and maintain Dynamic Arrays: public class DynamicArrays { private Integer[] input = new Integer[1]; private Integer length = 0; private Integer ...
-1
votes
0answers
16 views

How to access Authentication-based Web Service, and transfer to Json? [on hold]

I use Restful Service to communicate between frontend and Java backend. Java side needs to access Authentication-based Web Service (needs username/password). The request and response of xml message is ...
1
vote
2answers
89 views

Is it worth it to use a message-queue framework in this case?

We have these things called "executions" that are run at certain times. They have a delay property that basically says "execute me after delay microseconds`. Currently we are using Cassandra as a ...
0
votes
1answer
36 views

Java Action Listener

Actually, I've got a confusion in Java while implementing action listener event. I can add action listener event by implementing the class with ActionListener and by ...
5
votes
4answers
728 views

Is the use of one-letter variables encouraged? [on hold]

Is the use of one-letter variables encouraged in Java? In code snippets or tutorials, you often see them. I cannot imagine using them is encouraged because it makes the code relatively harder to read ...
23
votes
10answers
4k views

What's the proper way to model this real-world activity that seems to need circular references in OOP?

I've been wrestling with a problem in a Java project about circular references. I'm trying to model a real-world situation in which it seems the objects in question are interdependent and need to ...
2
votes
3answers
120 views

How to use one web page to create and edit database entries

My team and I are developing a java web application which allows our admins to create and edit "methods" which can later be viewed by other users. We are currently discussing the best way to ...
0
votes
0answers
32 views

Design of a Smartcard listener [duplicate]

I have the task to write a listener which detects smartcards inserted into a terminal and notifies all registered classes. The listener needs to be accessible from different parts of a large ...
4
votes
3answers
238 views

When is an object of real world a (computational) object of your program?

In an OOP design phase strategy, Any physical/conceptual object of a system can be modeled(considered) as computational object in your OOP designed program based on below two conditions: First ...
0
votes
0answers
115 views

Comparing an object with a String using equals() method [migrated]

In the below example, I am expecting equals() to return true: public class flower { String flower; public flower (String flower) { this.flower = flower; } public static void ...
0
votes
1answer
85 views

What are the time and space complexities of this recursive method that reverses a singly linked list?

What are the Time and Space complexities of this Java method that reverses a singly linked list (of length n)? I'm more interested in knowing the reasoning behind the space complexity. Let me know if ...
1
vote
1answer
134 views

What would be the best way to implement priority based programming without adding too much of if-else processing logic

We need to add priority based programming in our application using java programming language. For example, there are three priorities that a phone can have: A1, A2 and A3. Also there can be three ...
0
votes
1answer
107 views

Design: Bridge Game

I'm making revisions to a Console version of contract bridge I made in Java. The source can be found here: Bridge So most of the code is terrible and I've been trying make improvements wherever ...
1
vote
1answer
281 views

Avoiding long list of interfaces

Motivation Let a project where... ... exists a lot different behaviors. For each behavior, there is an interface which has its possible actions. One object could perform a lot different behaviors. ...
1
vote
2answers
120 views

Non-null alternative to Void (Java unit type)

I have a map-like type SmurfMap<K, V> which in certain contexts I use as a set-like SmurfMap<K, Void>. Implementation details forbid the values of the map from being null, so I cannot ...
1
vote
1answer
94 views

Design pattern for ensuring the “signature” of generic lists is equal

I have an interface, Attribute, that is going to be implemented in various ways, class AttributeA implements Attribute{\\..} class AttributeB implements Attribute{\\..} Then I'm planning to have ...
1
vote
1answer
96 views

Is a class representing a JSON response a DTO, a domain object, or something else?

Consider a restful service in Spring MVC. I am wondering how to package my response classes, i.e. how to name the containing package. First I thought of them as being domain objects. But they are ...
0
votes
1answer
110 views

Converting from List<Object> to Array with threads

I have a large (>500.000) list of Objects and I want to convert it a multidimensional array. Until now I am doing this using a for loop, but after some measurements I identified that this is a ...
-2
votes
1answer
32 views

What is Multipart Image upload? [closed]

Can someone please explain what does Multi part image upload means and it's advantages. When should i use multipart image upload?
1
vote
2answers
44 views

Expressing interface inheritance in natural language [duplicate]

In object-oriented programming, when you extend a class you establish an is-a relationship between a new subtype and its parent(s), i.e. B is an A (aka code inheritance). When you compose a class with ...
1
vote
2answers
128 views

Designing Message class in Java

I'm writing a class for Message. Message comes with Header and Payload. Header has following fields: Version Type For Type "XYZ", the following Payloads are allowed. Configuration Metafile ...
5
votes
2answers
161 views

How do I deal with the following technical issue? [closed]

I am a Java Programmer and I am relatively new to Java(1 Year). I am working for a small startup company. My problem is a bit strange and I am facing it a bit difficult to deal with and explain also. ...
3
votes
3answers
105 views

Would implementing a “Throwable Event System” be abusive?

I have been thinking for a couple years now about using Throwable events and implementing a sort of event system that uses throw to dispatch an event, or let a different method handle it with throws. ...
-2
votes
2answers
95 views

How would you structure your code for a Neural Network? [closed]

I understand how Artificial Neural Networks work. However, implementing one in code is quite another thing. How would you go about designing the classes and data structures? I found one great ...
0
votes
0answers
21 views

How to illustrate the difference between forward and backward compatibility [duplicate]

Please correct me if I'm wrong, but a new version that can run old code is backwards-compatible and an old version that can run new code is forward-compatible (like an old B/W television can receive a ...
0
votes
1answer
45 views

Getters with data conversion in Java VOs

I am working on a standard Spring application where DAO layer returns entities to service layer and service layer returns VOs to other services and controllers. In a certain scenario, we have a VO ...
-1
votes
0answers
19 views

Weird Override and implementation [migrated]

I am currently programming an android app, but I have a problem. I want to use GreenDroid for my project but while compiling the compliler give me an error : The return type is incompatible with ...
3
votes
2answers
119 views

Domain object model: query by id vs object

Let assume I have two simple model classes: Product and Brand It is obvious I have a query method in Product class like this Product product = Product.findById(123); What if, I want to query ...
-3
votes
0answers
24 views

How to launch browser from Java WS and log on page by SSO?

I have an Java Web Start application which communicate with J2EE server application (JBoss). User is logging in (login & password) and after that doing some operations. Now I would like to add a ...
0
votes
0answers
27 views

Handling server failure using serialization

In my program, there is a central server, and I want to store its state. I'm using serialization for this, I am serializing the data after every 2,3 seconds. So that whenever server fails, it can come ...
1
vote
1answer
117 views

Differences in design/thought process for OO in Java and JavaScript [duplicate]

Despite sharing a similar name and syntax, Java and JavaScript are quite different. However, they both have Object Oriented features. As a JavaScript novice, the main differences that I can see ...
2
votes
3answers
134 views

How do I show 'creates' in a UML class diagram?

Let's say my code is going to look like this: public class MyController { private Foo foo; private FooGenerator fooGen; //setters public void work() { this.foo = ...
1
vote
3answers
172 views

Using prefix/postfix increment operator for simple incremental array access rather than actual index numbers

I cannot decide which method is better with consideration of both readability and fault-tolerance. Method #1: Object[] objects = getArrayOfKnownLength(); int i = -1; someMethod(objects[++i], ...
-2
votes
1answer
83 views

Java - Concept question: LinkedHashMaps vs POJOs?

EDIT: I'm just going to ask a single question instead of presenting a problem and asking for advice on a specific design decision in the solution. Given a batch of data from a database, collected ...