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
5answers
212 views

Why do I need to declare virtual functions as such?

Example: We have a base class Base and three subclasses which all implement their own version of doSomething(). In an intermediate function f(Base b), we want to call the relevant version of ...
-5
votes
0answers
25 views

Twitter login through javascript [on hold]

I want to write only JavaScript code for twitter login and fetch logged user information like screen name , user link URL , user location etc.
3
votes
1answer
288 views

Is it OK to do IO inside java 8 streams?

Example to question in title: List<UUID> ids = dao1.getContactsOfUser(userId); List<String> contact_names = ids.stream .map(uid -> dao2.getContactByUid(uid)) //is it ok? ...
0
votes
0answers
21 views

Inheritance and Parcels

In Android development, we have Parcelable interface. Since I wish to build Data Models that will run on multiple apps and services (not just Android), I would like to add two jar libs that will share ...
-5
votes
0answers
51 views

Does programming language matters for a developer? [on hold]

I have close to 3 years of experience in Java + PHP. I want to know : 1) Does being a specialist expert in one programming language important ? or 2) Being good at problem solving, algorithms is more ...
1
vote
2answers
73 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
0answers
37 views

Where should we can keep the localization messages of the application?

I'm using ant's style of project directory structure for my java application like I shown in the pic. I know that the configuration files like dbconfig.propertiescan be kept in conf folder, but where ...
1
vote
1answer
50 views

Is this indexed approach to java rts game development valid and how can I improve it?

I have class GameState laid out to basically hold an Array of Players, an Array of StarSystems, and a few other fields that need to persist from save to save. Each GameObject keeps track of its own ...
-1
votes
0answers
29 views

J-Boss, Jackson, RESTEasy: what do these RESTful tools do?

I'm sure that question seems very asinine. I understand the purpose of these sorts of tools is to… Remove an unnecessary outer layer of Java servlet code that can be replaced by annotations. Handle ...
7
votes
3answers
200 views

Composable concurrency in Java or any other programming language

While I was reading a research paper on concurrency named Software and the Concurrency Revolution (html version). I came across following lines: Unfortunately, although locks work, they pose ...
-3
votes
0answers
56 views

Biggest palindromic number which is a product of two 3 digit numbers [on hold]

I've got to find the biggest palindromic number which is a product of two 3 digit numbers. I wrote a program for it in Java but something is going wrong. Here is the program I've written. public ...
-4
votes
1answer
69 views

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

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
40 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
37 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
129 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
510 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
117 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
125 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 ...
7
votes
5answers
185 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 ...
2
votes
1answer
116 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
74 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
128 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
360 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 ...
1
vote
1answer
72 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
374 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
59 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
106 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 ...
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
40 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
81 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
81 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
17 views

JOptionPane check dialog to a String [closed]

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 ...
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
40 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
32 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
230 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
111 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
26 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 [closed]

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
54 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
61 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
81 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
215 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 ...