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
6 views

Building an API with one central connection object to an external device

I want to build an API (Java) that heavily relies on a connection object to a data server that manages a connection to a real device. All i have is a DeviceConnection object. Currently i have a big ...
-1
votes
1answer
34 views

Duplicate code to avoid performance decrease due to function calls? [on hold]

I have a simple list in Java that I need to search using one of two methods. The first method simply returns the position in the list of the first matching element. The second filters out any elements ...
-5
votes
0answers
28 views

Add simple GUI to Java program

I have Java program with two classes "server & client" (packet programming), and I need to add simple GUI for this program. Appreciate if anyone can help me .. Client.java import ...
0
votes
1answer
40 views

How do you deal with NULL values while creating jsonObject?

I am learning java and jsr-353. My question is quite forward. Having the method below: public JsonObject createJsonObject() { return Json.createObjectBuilder() .add("address", ...
2
votes
1answer
94 views

How can I find out network latency in rest service

I have two Java applications deployed on tomcat. For inter application communication I provide jar file of application (Java API) to other application and it becomes a method call which is fast. Now ...
8
votes
4answers
255 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 ...
0
votes
1answer
108 views

What kind of data structure should be used to store components in an electrical schematic program?

Is there a specific data structure, object oriented programming methodology, and/or approach for achieving what programs like LT Spice, Altium Designer, and Cadence Virtuoso use to manage ...
1
vote
1answer
42 views

Parameter objects place holder?

If a method has too many parameters, the suggestion is to convert them into a parameter object. Where to place such parameter objects? in domain/entity classes package? or if I have a separate package ...
3
votes
0answers
50 views
+50

Should use case/interactor `execute` method accept parameters

In most examples of clean architecture (Android projects mostly, though) I've noticed that the use-case/interactor classes (units that encapsulate a feature) often share base class/interface, like ...
4
votes
4answers
189 views

JSON API or Plain JSON

There is a debate in my company on whether we should use the JSON API specification or stick to plain JSON for developing APIs that will be consumed by mobile apps, mainly iOS and Android. One ...
-2
votes
3answers
76 views

Java Ellipses Signature for Multiple Parmeters

Firstly, I am studying function with new type of signature and body, and in this code, I want to know, what type of object is values? It doesn't appear to be an array of strings based on my ...
-2
votes
1answer
44 views

Java/OOP-Book for functional programmer [on hold]

I'm a functional programmer (mostly Haskell) and have some experience with OOP - I know how inheritance, overloading, ... work, also I have experience with low-level procedural languages like C. I'm ...
0
votes
0answers
18 views

Concept analysis: using a Java ServerSocket to let an Android phone and server communicate?

I have an idea for an application that will not be published to the public Play Store. My friends will need to be able to log in from their Android phone to view certain data that cannot be viewed by ...
30
votes
6answers
15k views

Why avoid Java Inheritance “Extends”

Jame Gosling said “You should avoid implementation inheritance whenever possible.” and instead, use interface inheritance. But why? How can we avoid inheriting the structure of an object using ...
0
votes
3answers
155 views

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

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 ...
15
votes
5answers
6k views

Proper workaround for multiple inheritence in Java (Android)

I have a conceptual problem with a proper implementation of code which seems require multiple inheritance, that would not be a problem in many OO languages, but as the project is for Android, there ...
0
votes
1answer
112 views

NoSQL in Java Enterprise Application

I'm planning a large scale enterprise application that requires reliability and standardization comfort that Java EE provides. At the same time, I'm wondering if I go for Java EE, will I be able to ...
-2
votes
0answers
68 views

How can I prepare myself for programming in PhD research? [on hold]

My background is in Computer Science but I'm not practising programming since a long time so I only remember how to decalre a variable and assign it a value (in Java). In 6 months time I'm going to ...
0
votes
0answers
39 views

Embedding custom business logic using Javascript in Java application

We have an application where the front-end is completely rendered dynamically. The web page is stored as JSON in the database. A simple JSON to display input field with a label is as follows: { ...
2
votes
5answers
304 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
36 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
306 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
27 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 ...
1
vote
2answers
74 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 ...
1
vote
1answer
67 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
35 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 ...
-3
votes
0answers
66 views

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

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 ...
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
514 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
122 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
199 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
83 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
117 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 ...
-1
votes
0answers
83 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 ...
1
vote
1answer
361 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
75 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
376 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
110 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
261 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
86 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
82 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
18 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 ...
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
231 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 ...