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

0
votes
0answers
15 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 ...
14
votes
7answers
9k views

Reasons for a Java Developer to learn RoR

Just wondering if there are any reasons why a Java developer should learn Ruby on Rails knowing that there are technologies such as Grails or (especially) Spring Roo that can be more familiar?
0
votes
1answer
20 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
639 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 ...
18
votes
7answers
2k 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
2answers
86 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 ...
1
vote
1answer
309 views

DataMapper for a MMO game plugin to send packets

I am working on an plugin for some game-server. The information about the plugin is not really necessary. Few points you might find helpful to answer to this question: The server The server is ...
55
votes
9answers
9k views
+50

How do you avoid getters and setters?

I'm having something of a hard time with designing classes in an oo way. I've read that objects expose their behavior, not their data; therefore, rather than using getter/setters to modify data, the ...
1
vote
1answer
102 views

Non-fixed-size Fenwick Tree implementation

I'm planning to implement a non-fixed-size Fenwick tree. That is, a Fenwick tree that allows interleaving range queries with adding/removing elements. All implementations and samples I've seen so far ...
-5
votes
0answers
86 views

Would it be put me in risk if I use open source software? [on hold]

I have came across the web and found that GWT online toolkit which enables to use JS, XML, JSON integrity with java applications. But this seems to be an open source. In my workplace, it should not be ...
83
votes
10answers
52k views

How do you unit test private methods?

I am working on a java project. I am new to unit testing. What is the best way to unit test private methods in java classes?
0
votes
0answers
31 views

Design of a Smartcard listener

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 ...
5
votes
2answers
144 views

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

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. ...
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
91 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 ...
4
votes
3answers
230 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 ...
1
vote
1answer
272 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. ...
0
votes
2answers
538 views

Is factory pattern a right pattern for the situation described here?

Is factory pattern a right pattern when we want to consolidate the related objects? Problem - In the Set-top box, I have a user-io, basically the interface to control the settop box - The user-io can ...
1
vote
1answer
130 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
80 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 ...
0
votes
1answer
101 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
4answers
1k views

Why 'List<E>' is an 'interface' but not 'abstract class'?

Amidst defining the hierarchy, firstly, one can think to embed the abstract method(behavior) in abstract class only because the derive concrete class possess that behavior as core behavior with it's ...
0
votes
2answers
116 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 ...
3
votes
4answers
1k views

How to force “program to an interface” without using a java Interface in java 1.6

In java 1.8 they have wonderful new "default interface methods". In 1.6 how close can we come? The goal: use code to keep clients from being able to tell that a class is not a java interface. If we ...
4
votes
4answers
190 views

Single method with many parameters vs many methods that must be called in order

I have some raw data I need to do many things to (shift it, rotate it, scale it along certain axis, rotate it to a final position) and I am not sure what the best way to do this to maintain code ...
2
votes
1answer
182 views

Debugging xml and annotations

By now, most web containers have an annotation variant of their xml configurations for Java EE. I'm guessing this is because it's better to keep things in Java where they can be managed, coded with ...
1
vote
1answer
91 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
107 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 ...
9
votes
6answers
402 views

Does it always make sense to “program to an interface” in Java?

I've seen the discussion at this question regarding how a class that implements from an interface would be instantiated. In my case, I'm writing a very small program in Java that uses an instance of ...
1
vote
1answer
286 views

Is this database design good? What JPA Entities should I create for this design?

I am trying my hands on JPA. For this I am thinking of using the example of a student admission process as shown in the diagram below. Is this design good ? Any suggestions for improvement are ...
1
vote
1answer
109 views

Java partial enum backed by the database

I have following problem: need to use enum in my java code, since I'll have to ask in my business logic things like if(someting == enumname.VALUE_ENUM){... but I don't have all the enum types at the ...
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 ...
-2
votes
1answer
30 views

What is Multipart Image upload? [on hold]

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
125 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 ...
-2
votes
2answers
88 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 ...
-6
votes
0answers
22 views

How to align a nucleotide sequence against a set of them in a database? [on hold]

How to align a nucleotide sequence against a set of them in a database? Need a sample Python , Java or Ruby code showing the alignment of an input 1000 bp sequence against a set of them. I could find ...
0
votes
1answer
43 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 ...
3
votes
3answers
100 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. ...
4
votes
1answer
208 views

Is Collection.stream().filter().forEach() inefficient compared to a standard for each loop?

IntelliJ IDEA recommended to me just now to replace the following for-each loop with a Java 8 "forEach" call: for (Object o : objects) { if (o instanceof SomeObject) { ...
3
votes
2answers
116 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 ...
-4
votes
0answers
26 views

How do I solve this java problem? [closed]

I cant solve this problem which is given by AIDE ANDROID APP Please tell me the answer(because i am a beginner) I know it is simple but i am confused with that "mean" error please help me! Q- Now use ...
-4
votes
0answers
33 views

Shadowing vs Inner class's access only to final variables [closed]

In Java : Shadowing allows us to modify any variable with same name in an inner block but how is it possible when we have access only to final variables in an inner class?
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 ...
1
vote
3answers
168 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], ...
-1
votes
0answers
35 views

Which patterns to apply for “User Manager” [closed]

I developing a social application and I neeed to create a User Manager that is responsible for managing certain types of user. A user who enters in to the system will be a new user or an existing ...
43
votes
7answers
8k views

How to deal with static utility classes when designing for testability

We are trying to design our system to be testable and in most parts developed using TDD. Currently we are trying to solve the following problem: In various places it is necessary for us to use static ...
4
votes
1answer
380 views

Which patterns/architecture to apply for “Import Data, Process Data, Export Result”

I was wondering which architecture/patterns to choose for the following problem divided into three steps: Import TestScript Description from File (e.g. .xls, .txt) Process Described TestScript ...
-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 ...
5
votes
2answers
352 views

Is it possible to use the Android layout system in a desktop java application?

I am lazy, thus, if possible, I would like to only have to design and program a UI once. If I want to create an App for Android and as a basic Java desktop application, is there a way to reuse the UI ...
1
vote
1answer
114 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 ...