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
2answers
81 views

Using Super.someMethod for added clarity?

Is Super.someMethod() a good practice to add clarity to the code by explicitly stating that someMethod is not a method included in the current class but in the parent class? For instance, would this ...
2
votes
2answers
126 views

Unit testing / How to validate private fields of a newly created object?

I have a basic unit test (for the sample) that involves this code: void testShouldCreateACar() { Car car = someone.createFerrari(); assertTrue(car.name == "Ferrari"); // can't access name since ...
0
votes
1answer
196 views

Java is not actually a pure object oriented programming language since it needs primitives Why?

here my Question it is said that "Java is not actually a pure object oriented programming language since it needs primitives" I want to know that how data types can affect to java be an pure object ...
0
votes
1answer
80 views

strategy to display value for a html select

Strategy to display value for a html select I have a spring boot, application. On the client side, I use JQuery I would like to know the strategy to display "static value" for a html select. ...
1
vote
0answers
69 views

Should I annotate all the entry points in my library?

In a library project, I see numerous warnings suggesting that I reduce the visibility of public classes and methods. (Or in the case of methods I haven't written tests for, warnings about them being ...
0
votes
1answer
140 views

Isn't instantiating an object of type Interface illegal?

This answer describing how Spring for Java works instantiates an object of type Interface which is illegal yet it received 21 upvotes. Why is this answer upvoted for illegal behavior? Spring contains ...
2
votes
4answers
204 views

Must a variable contain an instance of a class if it invokes a method?

In the following link, the author states that We have already reasoned that ‘out’ is a static variable belonging to the class System. But now we can see that ‘out’ must be an instance of a class, ...
0
votes
0answers
61 views

Complexity of ArrayList and LinkedList

Suppose a Java method receives a List and reverses the order of the items it contains by removing each item from the front of the list, adding each item to a Stack, and then removing the items from ...
4
votes
3answers
316 views

Why instantiate and initialize an object without saving it into a variable?

Sorry if I got the wording wrong in my title, but it would be easiest to provide an example in JavaFX primaryStage.setScene(new Scene(grid, 300, 275)); Now from what I understand, this code is ...
0
votes
1answer
91 views

Android Studio, HTML and Java Correlation

I've recently started designing apps in Android Studio, and I've noticed that the same operations (for example, using a widget) can be completed by either going into the activityname_java file and ...
1
vote
1answer
145 views

Design decision: class hierarchy or Java 8 Optional

I am really reconsidering my current class hierarchy for timeslots (in a schedule). I wanted to make them as flexible as possible so it would cover many possibilities of what we could understand as a ...
1
vote
2answers
204 views

multi-threading performance when CPU is maxed out

I've noticed my software severely degrades when the # of threads is substantially increased. What I mean is that when I limit the # of threads, the performance is much better than when I just let ...
0
votes
3answers
145 views

Why do I want this class to extend an interface, and what is the right design pattern for this?

Suppose I have an interface Employee and there are many classes that implement it, such as Bob, Joe, and Mary, none of which may be changed. public interface Employee{ public void work() } public ...
0
votes
0answers
50 views

Background application which pops up a UI based on events

I need to code a Java Application which runs on the desktop. It's a continuously running application. It runs all the time. It should not show any UI unless there is an event. The application ...
6
votes
0answers
243 views

What lambda function optimizations, if any, are planned for Java 9 and beyond?

I'm working on a high-performance project where Java 8's lambda functions are enormously useful. I've found, however, that they're memory inefficient when used en masse. For example, suppose I need to ...
1
vote
1answer
231 views

Why are there no cross-platform mobile applications?

As a part of my master's thesis, I am carrying a research topic on why there are no cross platform mobile applications. As applications developed in Java can run on any operating system using the JVM,...
1
vote
1answer
119 views

Polymorphic constants in Java

I am designing some polymorphic code to perform mathematical operations. The idea is to abstract out the underlying representation of the data, as different use cases require different representations....
-1
votes
2answers
82 views

Connecting an HTML form to a Java program [closed]

I would like to create a front-end interface in HTML that interacts with a Java program via an HTML form. I would like to be able to publish this project on the Internet. In other words, the text ...
-1
votes
1answer
70 views

About data intensive and form intensive web applications

Can someone please highlight the definition and differences between data intensive and form intensive web applications.It would be really helpful if suitable java based web application framework or ...
0
votes
0answers
18 views

Layout for Java Multi window applciation

I need to get to know how to architect my an application with multiple windows. It has a dashboard kind home or main window with few icons(12 or more) on it. Clicking on an icon it will open a ...
3
votes
1answer
132 views

In Java, why is there no instance method like bigDecimal.isGreaterThan(otherBigDecimal)?

The current way of knowing if a BigDecimal is greater than another is bigDecimal.compareTo(otherBigDecimal) > 0 (or one.compareTo(another) == 1), but I find it too clunky and unexpressive. ...
2
votes
3answers
243 views

Why do assertions in Java need to get enabled?

I really like the concept of assertions in Java in the way how to use them. It's much easier than to write an if and then throw an Exception/Error. But the thing I don't understand is, why do they ...
3
votes
1answer
190 views

Why Generic type can not instantiated?

Here is my question. class Gen<T> { T ob; Gen() { ob = new T(); // Illegal!!! } } Why is it illegal? Could you please explain it.
2
votes
1answer
107 views

Best way to deliver and deploy JEE application to client

I've worked for a few companies and even developed projects on my own - these projects were based on Java Enterprise Edition. Sometimes with Spring Framework involved, sometimes it was a pure JEE. ...
0
votes
1answer
100 views

Designing a program that runs scrtipts on multiple computers(JAVA)

So Ive been trying to design a program in java(because I might need to create an app that does the controlling part) with GUI that can run scripts on a few local computers. It should do the following: ...
82
votes
9answers
8k views

Has / can anyone challenge Uncle Bob on his love of removing “useless braces”?

I hate referencing paywalled content, but this video shows exactly what I'm talking about. Precisely 12 minutes in Robert Martin looks at this: And says "One of my favorite things to do is getting ...
3
votes
2answers
85 views

RESTful service and DAO: deciding on responses

I am developing a RESTful API and I am using DAOs to serve data to the service. I am having trouble deciding where certain responsibilities should fall, whether in the service or in the DAO contract. ...
7
votes
3answers
479 views

Should a DAO be singleton or not?

I am developing a RESTful API and I think it is convenient to use DAOs for my resources because although I plan on just using memory to store them, I don't want to close a door to whoever is using my ...
-1
votes
1answer
137 views

How to allocate an Int32 number for a GUID string? [closed]

We want to allocate a Int32 value for a coming new GUID, which is not exist in our system. One solution is to use auto-incremental Id in Mysql, but it's not convenient for later usages. Another ...
5
votes
1answer
87 views

Designing a flexible API with support for Callbacks

I am writing a Java library that needs to make http GET && POST requests. There will be two types of users of this library: Those with understanding of callbacks and know how to use them. ...
5
votes
3answers
325 views

Is nesting try-catch statements still a code smell if nested within a loop?

I have heard that nesting try-catch statements can often be a code smell, so I'm wondering whether this situation is an exception. If not, what would be some good ways to refactor? My code looks like ...
0
votes
1answer
113 views

Is it wrong to call a “non-static nested class” an “inner class” in Java?

I was reading this question in SO, and it contains the following: A non-static nested class (sometimes incorrectly referred to as an 'inner class') (...) And it confused me. At 350+ upvotes, I ...
3
votes
2answers
223 views

How to cope with very similar projects

At our company, we maintain three products, which are quite similar, in 2 Projects. All Java, using Maven for dependencies. These three products evolved out of another project, which is now a maven ...
0
votes
2answers
52 views

Guava Multimap merging consecutive items with same key

I have been playing around with Guava Multimaps and I ran into an issue with tracking when an user is damaged (more the way it's displayed, really) Let's say I have a Multimap<User, Hit> and ...
0
votes
0answers
55 views

Should fragments register directly to an event bus or should only activites do so?

Please correct me if I'm wrong about any of the following. I understand that if a fragment wants to make a network call it tells it's activity then the activity makes the call and returns the answer ...
-1
votes
1answer
132 views

Using sessions with Jersey in a REST API

I am starting to develop a REST API with Jersey to retrieve a schedule for a given sport tournament. The client sends a JSON containing a tournament with its different categories, domain, definitions ...
0
votes
1answer
45 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 ...
-2
votes
1answer
100 views

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

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 ...
-1
votes
1answer
67 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", this....
2
votes
2answers
77 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 ...
0
votes
0answers
25 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 ...
-2
votes
2answers
93 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 ...
4
votes
4answers
259 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 ...
4
votes
1answer
223 views

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 ...
0
votes
0answers
55 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: { "...
0
votes
0answers
35 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
1answer
73 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 id,...
1
vote
2answers
76 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 ...
0
votes
1answer
117 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 ...
0
votes
3answers
170 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 ...