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

1
vote
1answer
16 views

Passing and returning domain object in create method

We have this bean with two properties: ContainerImage + name (final, not null) + id (null) Then there is this method: ContainerImage create(ContainerImage containerImage); It receives ...
-2
votes
1answer
29 views

How to Know if my code is good, clean, maintainable or just code that works?

I Learned JAVA Programming from the Internet (not school) So whenever I need to code something I just see a lot of tutorials and then based on their code I try to produce my own version of code, ...
-3
votes
0answers
25 views

Looking to see if my understanding of parent to child relationship is correct [on hold]

new to java and was just wondering if this would be correct. Appliance would be parent class with attributes like brand, power in watts, power button:on/off. The child class would be like air ...
-3
votes
0answers
29 views

not able to create a package in eclipse under java folder [on hold]

I am trying to build a hello world program in jsf/maven eclipse by following http://www.tutorialspoint.com/jsf/jsf_first_application.htm. The steps i performed so far 1: mvn archetype:generate ...
2
votes
1answer
115 views

Choice of variable names and types in graph algorithm

I am learning algorithms and data structures from this awesome resource Algorithms. Rather than doing dry reading I am trying to re-write all the code myself so that I can learn coding as well as ...
2
votes
4answers
480 views

Why isn't there a primitive “complex number” type in Java?

Does anyone know why something like http://www.ipd.uka.de/JavaParty/cj/#Down was never completed and integrated into mainline java? This seems like a no-brainer... I realize the java gawds dont want ...
2
votes
2answers
110 views

Placing preconditions in the right place

I am trying to figure out the best way to define the responsibility of checking preconditions. Let's consider the following case: we have an Event class representing a sports event and a Matchup ...
1
vote
2answers
124 views

Designing validation classes

This is a follow-up of this question. I decided to implement what the accepted answer suggests, however, I realized I also needed individual public methods for each member the entity to be validated ...
-3
votes
0answers
22 views

Text field user input to display list of specific files in directory in Java [on hold]

I'm very new to Java, I was looking through the forums and although I found similar answers to my problem, and tried to follow the format of some solutions I have found, I am still having difficulty. ...
7
votes
5answers
183 views

Open Closed principle in design patterns

I am bit confused about how Open Closed principle can be applied in real life. Requirement in any business changes over the time. According to Open-Closed principle you should extend the class instead ...
0
votes
1answer
81 views

How to setup multiple queries with slight differences

I'm writing a page that will show the user statistical data about some of our products. Basically the user can get results between a specific time frame, and also add on other data to lookup by. For ...
1
vote
1answer
110 views

What are the limitations of Java exception approach to errors?

Please ignore performance issues, I am interesting in data flow, safety, modelling, reasoning. I wonder what are the limitations of exception approach to error reporting implemented like in Java ...
0
votes
0answers
67 views

Packaging a HTML,JS,CSS project within an application for security.

We have a project which is designed with html,css and JS. For demonstration purposes, we have integrated the project inside a JavaFX app in the webkit browser and from there we are just loading the ...
0
votes
3answers
122 views

A very basic question about whether I should check for null and throw NPE?

Consider the below method- public void operationOnList(List<String> list) { list.add(1); } It is obvious that if l is null this method will throw a NullPointerException. My question is ...
1
vote
1answer
358 views

JEE MVC, controller calls the interface instead of the interface implementation

I'm following this tutorial: http://wiki4.caucho.com/Building_a_simple_listing_in_JSP It creates a basic web application in Eclipse using the MVC pattern with Resin as the web container. Here's the ...
-3
votes
0answers
28 views

3D image view in java [on hold]

I want to write a java program to view the selected image in 3D form but I don't know how to begin. So please anyone help me suggesting the required API and necessary installations, If possible with ...
1
vote
1answer
70 views

When we need to serialize an exception

I have been developing in Java since 8 months, and I didn't face a case where I went to serialize an exception, I'm asking because I saw the serialVersionUID and how Eclipse advise to add it ...
5
votes
6answers
373 views

Dependency injection: should I use a framework?

I have recently worked on a Python project where we did dependency injection heavily (because we must in order for the app to be testable), but we didn't use any framework. At times it was a little ...
0
votes
0answers
58 views

Implementing logging interceptor next to BeanPostProcessors and BeanNameAutoProxyCreator

I want to implement simple mechanism based on annotation on method in different classes. The case is, that I have some beans created as a proxies with transaction interceptors like this: <bean ...
4
votes
3answers
103 views

Passing a private member collection to another class

Suppose I have a Map which is a private member variable of my class A. In the same class I create an instance of class B, call it objB, by passing the map to B's constructor. Obviously this is ...
1
vote
3answers
136 views

Why do I need to declare Virtual Functions as such?

Example: We have a Base Class and 3 subclasses which all implement their own version of "doSomething()". In an intermediate function (f(Base b);), we want to call the relevant version of ...
4
votes
1answer
260 views

Managing resource paths in source code

I suspect this is something that many of you have dealt with, and I'm certain there's articles on how to do it, but I can't seem to find them. My problem is that my various constant classes in Java ...
0
votes
2answers
39 views

Best Communication strategy for monitoring dashboard

I have a requirement where I need to display certain stats on Admin Dashboard in my web application (Angular+Java). These stats (transnational data) are being generated on different servers (connected ...
2
votes
2answers
74 views

C++ vs Java: Pointing to Objects

In Java: private State current_state; As "State" is a superclass, I can then assign subclass objects to current_state, effectively making current_state point to a different object: current_state = ...
3
votes
2answers
79 views

Creating Instances from same SuperClass Object

I have 3 subclasses (LowState, MediumState, HighState) which derive from the same superclass (State). Within the superclass, State, I have declared several variables which need to be accessed and ...
-3
votes
0answers
16 views

JOptionPane check dialog to a String [on hold]

So basically I want a input dialog to open up then, the user writes out an input. After that I check it to a String, if the String match I show them a message Dialog "Correct", if not show a message ...
-5
votes
1answer
73 views

How to generate random negative BigInteger in Java [on hold]

How to generate random negative big Integer in Java? For example if lambda=3, generate the Big Integer in range (-2^lambda,2^lambda). I have tried BigInteger(lambda,random) but this constructor ...
2
votes
2answers
530 views

How to efficiently handle related data in MVC?

Talking about MVC with servlets and JSP's, in a context about products and manufacturers , when querying the application for a list of products: the servlet loads a list of products from the ...
-4
votes
0answers
39 views

Nested Enumeration in java? [on hold]

I currently have six separate enums in java that all implement interface A. I cannot combine the enums because then I get a code too large error. The six enums solution works, but I cannot iterate ...
0
votes
0answers
31 views

Better way to model parallel implementations of specialised collection-like types

I am working with some wrappers for selection widgets on the web (in Selenium). They each have one "parent" type that represent the widget and another type for the options. Two interfaces are created ...
20
votes
7answers
22k views

Avoid too complex method - Cyclomatic Complexity

Not sure how to go about this method to reduce Cyclomatic Complexity. Sonar reports 13 whereas 10 is expected. I am sure nothing harm in leaving this method as it is, however, just challenging me how ...
1
vote
3answers
229 views

How to store many global variables?

I have around 30 not-changing "objects" (the amount of them is final, no more can be added or removed). Each object has an id as well as some booleans describing what the object is and what it isn't. ...
0
votes
2answers
107 views

Could Java XYZ implement (limited) Operator Overloading without breaking backwards compatibility?

Recently, I've been learning a bit more of C++ and the dangers and uses of operator overloading, and the readability boost it provides to arithmetic types (like Complex numbers). A while ago, I was ...
-3
votes
0answers
24 views

Certificate Subject Name Filtering - Glassfish [on hold]

We have an issue with our glassfish server which should only be trusting certificates with an appropriate Distinguished Name, Subject values - corresponding to certs added to the trust store. ...
0
votes
3answers
83 views

Cyclic dependency in this project design

I have 2 modules (containing multiple classes). Let's call them Module A and Module B. Module B has a dependency on Module A: Module B -> Module A. Now, I have created an utility class C, which A ...
-2
votes
0answers
30 views

Suggestions about simple app to teach in mini-class about Android [closed]

I'm a Computer Science student and I'm learning Android programming for about three years. My University asked if I would like to start a mini-class about programming on Android, I would have 2 days ...
2
votes
4answers
6k views

Exporting huge data into XLS in a web application [on hold]

I am developing a web application in Java/J2EE, in which I have export functionality. I have used Jasper for the same. The issue is when trying to export a huge set of data it is consuming a lot of ...
0
votes
1answer
53 views

Naming conventions clashes when using postgres with jpa

I am using a jpa implementation which basically works on annotations with postgres database The postgres standards for naming field names is snake_case where as it is camelCase in java is there any ...
2
votes
4answers
260 views

Is it strange for a Builder object to have getter methods?

I have a fairly complex immutable data type that I'm using a builder object to instantiate. Currently, I have a setup where I parse a file, setting various fields in my builder, and then build the ...
5
votes
1answer
60 views

Discoverable default implementation of an interface

I have a couple of simple classes that implement the Null Object pattern. To illustrate the hierarchy, let's define a Config interface with two classes implementing it ConfigItem and MissingConfig, ...
16
votes
2answers
1k views

Java: why do collections accept a Comparator but not (a hypothetical) Hasher and Equator?

This issue is most apparent when you have different implementations of an interface, and for the purposes of a particular collection you only care about the interface-level view of the objects. For ...
2
votes
1answer
80 views

Should I return Iterable or Enumeration in Java

In order to achieve better immutability, should my API return java.lang.Iterable<T> or java.util.Enumeration<E>? Since Iterable has a remove() method, one could say Enumeration is the ...
0
votes
3answers
209 views

DDD Request Validation Handling

I stuck somewhere that I can't find a solution! There are plenty of validation questions here, but as far as I see, most of them were asking about entity validation. But what about request validation? ...
4
votes
2answers
214 views

Generating Java Classes with Compile-time Value Parameters

Consider a situation where a class implements the same basic behavior, methods, et cetera, but multiple different versions of that class could exist for different uses. In my particular case, I have a ...
48
votes
10answers
11k views

Why would the 'final' keyword ever be useful?

It seems Java has had the power to declare classes not-derivable for ages, and now C++ has it too. However, in the light of the Open/Close principle in SOLID, why would that be useful? To me, the ...
1
vote
1answer
21 views

Redesigning schedule value hierarchy

I have a couple of schedule value classes that represent the value a schedule holds for a specific slot. First, there's the ScheduleValue class for schedules with two dimensions, where the first one ...
2
votes
2answers
93 views

Image resizing client side vs server side

When uploading a lot of images to a server, to minimize the space taken by the images, is it better to resize the images before sending to the server or upon receiving them? It seems to me that ...
2
votes
2answers
109 views

Should we add an extra class to this code sample

I have a shopping website which allows users to place orders. In my web application when the users click 'Create Order' i call an OrderService class which looks like the below: public class ...
-2
votes
0answers
24 views

Schedule Timer on Main Thread [closed]

How would I schedule a timer in my main thread? Right now I'm having bit of a multi threading issue and figured it'll be better if I could just run my game on a single thread.
3
votes
5answers
293 views

In which layer should validation be located?

I'm creating a Rest API using Spring Boot and I am using Hibernate Validation to validate request inputs. But I also need other kinds of validation, for example when update data needs to checked, if ...