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

96
votes
13answers
14k views

Should we avoid language features that C++ has but Java doesn't to increase maintainability? [closed]

Suppose I am limited to use C++ by the environment in the project. Is it good to prevent the use of some language features that C++ has but Java doesn't have (e.g.: multiple inheritance, operator ...
1
vote
1answer
73 views

Is IntentService an implementation of Command Pattern?

According to Wikipedia: In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or ...
1
vote
2answers
155 views

For what reasons Java and C# initialize static data on demand?

I am reading "The Go Programming Language" right now and I have read package initialization chapter which tells (or I read it wrong) that Go uses eagerly initialization. So in time we saw say C++ ...
1
vote
3answers
231 views

Java need to call many methods systematically

I have a group of methods that is going to be very large. I need to be able to call methods systematically from a large group, in two different ways. The methods create a new item object with ...
0
votes
1answer
57 views

TDD with a half baked Java EE application

I am a second year Computer Science student currently on a placement and I am currently developing a Java EE application that collects meta data from several sources and then visualises the data. This ...
1
vote
1answer
104 views

Intelligent builder pattern - different parameters depending on type - generics?

Lets say we have the famous Joshua Bloch Nutrition Builder and we want to change it so it be a bit like dynamic builder which restricts visibility of setters and propably uses generics : public ...
3
votes
1answer
106 views

what happens at Java interpreter level when IncompatibleClassChangeError is thrown?

I am a noob at JVM internals. Can someone explain what happens at Java interpreter level when IncompatibleClassChangeError is thrown? I am facing an issue similar to the one described here: ...
1
vote
1answer
41 views

A way to update a list an Android application displays

I just started working on an Android app that should display posts from my site and then a three-column list of some products. The three columns on the list contain the product names, a short ...
4
votes
5answers
465 views

How to design a complex REST API considering DB performance?

I've been following some tutorials on how to design REST APIs, but I still have some big questions marks. All these tutorials show resources with relatively simple hierarchies, and I would like to ...
1
vote
2answers
250 views

Why use XML in android?

From what I understand, isnt xml used for layouts and to setup how an activity looks? My book says that xml files are converted into java code, but then, why not just write everything in java?
2
votes
2answers
175 views

Where is the class itself stored at runtime to be used as a reference

In C# or Java we find that the objects are stored on heap and their reference vars are stored on stack. But at run time where is the class definition stored to be used as a template for creating ...
0
votes
1answer
97 views

What is the difference between a 3rd party lib and a plugin

What is the difference between a 3rd party lib and a plugin? How do I choose what should be pushed to these repos? plugins-release-local = Your and 3rd party plugins (releases) ...
2
votes
1answer
49 views

Using prototype/non-Spring managed beans in Spring Web application

I have been working on few web applications/REST web services recently (Spring IoC/MVC/Data JPA etc) and they usually follow the same pattern: Controller classes --> Service classes (which have number ...
1
vote
2answers
165 views

How to deal with Classes having the same name (different packages)

My R&D team have Java packages containing classes with the same name. For instance: com.myapp.model Device ... com.myapp.data Device ... We had a discussion, the names conflict when both ...
9
votes
1answer
300 views

Enum with a lot of boolean properties

I'm currently working on a webapp where we often need to condition some server logic based on the page that is going to be returned to the user. Each page is given a 4-letter page code, and these ...
-2
votes
1answer
94 views

Problem on recursion

void function(int x){ if(x<=0) return; function(x--); } This is a recursion function which is called with the value of x = 20. The Recursive call will take place in this way ...
1
vote
3answers
206 views

Why would I need `equals` if I have already `hashcode`?

I got a question about why we need equals if we have hashcode. My first attempt was the answer because collision. But we corrected starting point with the assumption that we have not many objects so ...
1
vote
0answers
31 views

How can I test for performance issues in a specific piece of code? [duplicate]

I've inherited a problem from a programmer that isn't with our group anymore - a piece of our application suffers from performance issues under a particular set of circumstances. I can replicate ...
3
votes
3answers
115 views

What is “Split Data Model”, mentioned in the book “Java Concurrency In Practice”?

I'm learning Java multithreading programming by the book "Java Concurrency In Practice". In chapter 9.4.2 Split Data Model, I read this: From the perspective of the GUI, the Swing table model ...
1
vote
0answers
22 views

Correlating Search Classifiers in a Database Scan for Sensitive Information

Problem Description I am working on an enterprise data discovery project that is designed to scan databases for sensitive information. The basic search unit is called a classifier and covers things ...
4
votes
1answer
126 views

Name-Based Sorting Algorithms For Maximized Common Letters

I am attempting to write a program for a competition (we're allowed to consult Stack Exchange, as long as I'm not given physical code) that takes in a list of 5000 people's names (distributed fairly ...
1
vote
2answers
66 views

Should a client check for persisted item existence before modifying it?

I'm developing a MVC Web application with a REST interface. The REST controller performs actions on persisted items through a service class, which translates exceptions coming from the persistence ...
0
votes
1answer
252 views

Why is Eclipse platform dependent?

When Eclipse is written in Java and Java is platform independent, why does Eclipse offer different versions according to platforms? I assume it should be write once, use anywhere code.
-2
votes
1answer
53 views

Do any Java libraries support batch sql query processing and proceeds even if any duplicate records exists in the batch?

Is batch processing possible in jdbi with the below condition? If one insert query in the batch fails because of violating some constraints ( Primary key, foreign key violation.. etc) will it resume ...
1
vote
1answer
59 views

Amazon Echo Development on LAN

I have followed the tutorial from Amazon to get started with the Echo. I made a skill and setup an application server on their AWS Lambda for basic testing. I have a few questions about the Echo, ...
1
vote
1answer
130 views

Javascript Closure Style Similar to Java Class Structure

PROBLEM: There is a coding imperative (S. McConnel, Code Complete) that one shouldn't code on language, but by means of it, e.g. doing right style things even if language doesn't have some ...
2
votes
1answer
114 views

How are objects treated in an anonymous inner class?

Lets take this for example... entryText.addTextChangedListener(new TextWatcher() { TextView wordCount = (TextView) findViewById(R.id.wordCount); TextView charCount = (TextView) ...
-1
votes
0answers
83 views

Programmatically fix broken Java source code [migrated]

I'm currently creating a grading utility for my university that compiles, lints, run professor-defined tests, etc. In the process, I'm generating a parse tree of the student's source code so I can do ...
0
votes
1answer
57 views

Accessing information between GUIs in Java

I'm fairly new to Java and GUIs and am trying to work on a side project. I'm finding that as I continue to make more and more GUIs within eachother, I am continuously needing to access information ...
6
votes
2answers
162 views

Strategy Pattern Implementation

I have to generate a code that will send through SMS or Email to implement the One Time Password (OTP) requirement of our client. I just finished creating the design using strategy pattern, . . This ...
0
votes
0answers
16 views

Mapping symmetrical relationships in Hibernate [migrated]

I have a User table and a UserRelation table (simplified example). A User may have 0 or more relations to other users. The UserRelation table has two columns: user1 and user2. Currently I have this ...
0
votes
0answers
67 views

How to properly index MongoDB with ElasticSearch?

we are working on a JAVA EE project which handles huge amount of data, but has to provide full-text-search option (in hungarian language). So we started to think about what kind of architecture could ...
1
vote
0answers
35 views

Why is conditionally using an empty panel in Apache Wicket a bad practice?

When Apache released its list of best practices, they recommended avoiding the addition of an empty panel conditionally and gave the following example of what NOT to do: ...
13
votes
5answers
493 views

Broken Old/Legacy Unit Tests

I work for a big company and I'm responsible for a large java application with thousands of junit tests. Since I moved to this role, there have been 200-300 broken tests (likely broken for years). ...
6
votes
1answer
124 views

Why was conversion between Instant and Date named the way it was?

When Instant was introduced with JSR-310, convenience methods were added to perform conversion between Date and Instant: Date input = new Date(); Instant instant = input.toInstant(); Date output = ...
17
votes
8answers
2k views

Refactoring a long method which is based on large number of switch cases [duplicate]

We are using Java as a backend development language. One year back, we wrote a method which uses switch cases based on Enums values. Since we are continuously adding enum members and according adding ...
0
votes
1answer
35 views

Handle publishing data across environments

I am rewriting a website that has a back-end database for containing meta-data that is displayed to the user when they enter a text code. Background: The old/existing system stored this data in XML ...
5
votes
4answers
412 views

Does making a method static save memory on a class you'll have many instances of?

In response to Aaronaught's response to the question at: Can't I just use all static methods? Isn't less memory used for a static method? I am under the impression that each object instance carries ...
3
votes
2answers
104 views

Automatic Downcasting

I'm making a framework in Java and have a method in my abstract class, BasicPhase, called processAction (snippet below). It takes two abstract classes as parameters since the user should implement ...
2
votes
1answer
100 views

Pass request as argument to service client vs. pass service client as argument to request [closed]

I need a design recommendation: I have a class that send a http request via another class WebServiceHandler() I am hesitating between the following two implementations, which one to choose?which one ...
7
votes
6answers
1k views

Does it make sense to use the term “Space Leak” with regard to Java?

EDIT: To clarify, I am not suggesting that leaks don't happen in a managed application. I'm simply pondering about how we talk about them. There are some highly upvoted discussions about memory ...
0
votes
1answer
55 views

How confusing is `new SomeCollection(values…)::contains` as a Predicate? [closed]

Traditionally, a function that want to skip certain items during processing will accept a Collection or var-args argument, but in the Java 8 world I think I should switch to Predicates. Now, since ...
1
vote
2answers
81 views

Testing using mocking, must I mock all dependencies too?

I have the following method to test: public List<MarkId> getMarkIdList(ICar carDoc) { ICourseCar courseCarDoc = courseCarRep.get(carDoc); List<MarkWag> markWagList = ...
1
vote
1answer
63 views

Refactoring pattern Split Temporary Variable vs collection variable

We are using Java as a backend development language. We are using a List variable as method() { List recordsList = new ArrayList<Record>(); . . recordsList.add(records); . . ...
-4
votes
2answers
60 views

Store Android file to cloud and compare on application installed [closed]

I want to make my app secure from attackers and I want to do the following to prevent my app to be cracked: Store my Java file to the cloud (before publishing the app) User install my app and on ...
1
vote
3answers
137 views

When a class represents a property that might be invalid, how should the validation be done?

I have a Product class which has among others an attribute Ean13 that encapsulates an EAN13 code. Here is a prototype of the Product class: @Entity @Table(name = "tb_produtos") public class Product ...
2
votes
2answers
104 views

Domain driven design - Entity is updateable in certain circumstances

Here is my business rule: Anyone (anonymous users) can make an Application (as in to apply for something). Applications can be updated until they are reviewed and approved by an officer. Approved ...
0
votes
0answers
67 views

Compute the permutations for a set of numbers and then run each to find every possible schedule that fits a client constraints

I am building a Java program that computes the permutations for a set of numbers and then runs each of those permutations to find every single possible schedule that fits a client constraints. The ...
5
votes
2answers
193 views

How to get around non-initialized objects in the `finally` block?

I like using final variables whenever possible. Often those variables have to be closed afterwards. Note that I'm currently working on Java 6 so there is not closeable interface, but the same applies ...
0
votes
0answers
17 views

Which design pattern for interaction with miscoded project [duplicate]

I am actually working on JavaEE application (Spring, Hibernate). I have an old project which is not well coded. I have to not modify any line of code on it. And I have to add classes that uses this ...