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

3
votes
3answers
248 views

Is the use of one-letter variables encouraged?

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 ...
17
votes
7answers
1k 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 ...
-5
votes
0answers
85 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 ...
2
votes
2answers
81 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
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 ...
4
votes
3answers
226 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
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 ...
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
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
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
115 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 ...
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 ...
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 ...
-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?
-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 ...
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
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 ...
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. ...
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. ...
-2
votes
2answers
88 views

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

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 ...
-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
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 ...
0
votes
1answer
42 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
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 ...
-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
votes
0answers
42 views

Spring-Quartz scheduler throw NoSuchMethodException [closed]

I'm using Spring MVC to develop my project and I want to use quartz-schedule to set time for an method in controller. But there is java.lang.NoSuchMethodException occurred. This is my declared code: ...
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 ...
2
votes
3answers
131 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
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], ...
-2
votes
1answer
81 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 ...
2
votes
2answers
165 views

return a object without returning the reference

i'm having some trouble with returning objects and lists of objects. To problem is I want to return a object in my example an developer but I don't want to give the reference. What's the best ...
0
votes
1answer
62 views

how can the presenter or view interact with the model in the MVP pattern?

I'm learning the MV* patterns. MVP in this case. I'm trying to refactor an old android application into the MVP pattern to make things less tightly coupled, but I'm struggling one one concept. I know ...
4
votes
5answers
445 views

Is it okay to go against all-caps naming for enums to make their String representation simpler?

Several times I've seen people use title-case or even all lower-case naming for enum constants, for example: enum Color { red, yellow, green; } This makes working with their string form ...
0
votes
1answer
53 views

Using Websocket for a multiple-page website

Is using Websocket (in particular, in a Java, SpringMVC webapp, with the Spring Websocket support libs, but the question probably applies to any language) for a multiple-page website a bad idea ? ...
5
votes
2answers
189 views

Does sun.misc.Unsafe give access to the system or just the JVM?

Please note: Although this question involves microcontrollers, it is at its core, a Java question, and so I believe it can be answered by any battle-weary Java guru. I stumbled accross this blog ...
1
vote
0answers
42 views

Will using a pure MQTT approach be the right decision?

I plan to provide additional functions for a closed-source 3rd party point of sales application. That application is used in restaurants, is run on Windows and uses dbase style databases. I know the ...
55
votes
9answers
8k 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 ...
3
votes
3answers
157 views

Design suggestions for converters in Java

I'm trying a set of converters which will convert an object to some older form. And there are different objects which are converted. By older form I mean changing the values of some fields and in case ...
6
votes
3answers
180 views

Advantage/Disadvantage of having all variables declared in a JUnit Test

I've been writing some unit tests for some new code at work, and sent it off for a code review. One of my co-workers made a comment about why I was putting variables that are used in a number of those ...
14
votes
2answers
1k views

Declaring a class final? [duplicate]

I like my code to be written well; however, I have run into not really an problem, but more of a question about conventions. Say I have this class. public class Test { public void doStuff() { ...
0
votes
0answers
28 views

Run fat jar as a service on Amazon Linux EC2 instance using Ansible

I want to deploy a Ninja app to an EC2 Amazon Linux instance using Ansible. Being a Linux noob and completely new to Ansible, I wonder what the best way would be to start the app via Ansible as a ...
0
votes
1answer
37 views

Java: Weighted Selection help [closed]

I have this code that randomly selects a item from a enum. Each of the enum items have a integer weight to it. The higher that weight is, the higher chance that item has of being picked. Here's what ...
0
votes
1answer
144 views

I need a data structure for a card game

I am programming a card game in java, and unsure what data structure I should use for the player's hand. I considered using an array, with one integer to traverse the array and another integer to ...
2
votes
1answer
95 views

What is the motivation behind the @ImplementedBy annotation in Guice?

I recently read about the @ImplementedBy annotation available in Google Guice. It allows the programmer to specify a binding between an interface and its implementation for future use in dependency ...