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
1answer
77 views

Reference variable concept (Java)

I'm working my way (slowly, but surely) through a book: Introduction to Java Programming, 10th edition, Comprehensive, by J. Liang (ISBN10: 0133761312) It explains the idea of a reference ...
-1
votes
0answers
41 views

How should I use POJO in Scala?

I have created a Scala project that has Java dependencies at very low level (model, repository, etc.). Should I create implicit conversions to decouple it from POJO?
1
vote
5answers
180 views

How to optimize performance of sequential condition checks in Java?

I am writing a program that looks for a solution of a diophantine equation. The program is cycling for (int d = 0; d <= max; d++) { for (int c = 0; c < d; c++) { boolean ...
1
vote
2answers
99 views

When interacting with an ArrayList over REST will a ReadWriteLock maintain consistency?

I have an ArrayList of objects that may be added/deleted/updated via REST calls. In order to prevent issues that may result from concurrent accesses, will a ReadWriteLock be appropriate, and efficient?...
1
vote
2answers
61 views

How can I efficiently add/delete/get sorted data in Java?

I am writing a telephone directory program and need to store the entries in a CSV formatted file. However, I am having difficulty keeping the entries in order when adding. I was considering reading in ...
2
votes
4answers
130 views

Should CRUD actions be Java classes?

I am working on a simple project developing a telephone directory application. As such, it requires the implementation of the CRUD actions. Right now I have them as individual classes (e.g. "AddEntry")...
4
votes
2answers
142 views

Are API-changes expected in beta releases?

In an open source framework deprecated APIs were removed during the beta phase on the road to a new major version. Now users request to restore some deprecated APIs because it breaks compatibility. ...
0
votes
1answer
280 views

How to solve this seating problem?

I was solving a seating problem whose solution seems trivial but I am not able to get it. The problem states in short that we have to seat n (even) students in n/2 rows where students are labelled ...
0
votes
0answers
37 views

Profiling a java application making a lot of external http calls

I am having a java application which makes a lot of external http calls. To identify the hot methods I have used System.currentTimeMillis() in all methods and I observed that the methods who are ...
2
votes
2answers
129 views

Java: Composition of classes implementing same interface

Let's consider an example wherein I have to model the following: Class to schedule exams for a Student, lets call it StudentExamScheduler Class to schedule exam for a Class. Let's call it ...
1
vote
4answers
300 views

why can't class directly take arguments instead of using a constructor?

I referred this page for understanding about constructors in Java: http://www.javatpoint.com/constructor So, I pretty much got it as in my own words: constructor has no return value and is used ...
-1
votes
2answers
175 views

Why is the syntax for a new object creation is little bit long in java? [duplicate]

After trying to write small programs with out reading much of the concepts in Java, the following syntax bugs me a little: Car volvo = new Car("Sweden"); class Car { String country; // ...
0
votes
0answers
19 views

Asynchronous SOAP web service using Axis2 ADB

I am trying to implement a asynchronous method to send SOAP messages to a client. I have a web service for which I use SOAP to communicate with the client. I am the server and I send SOAP xml messages ...
-1
votes
1answer
157 views

Want Some Advice on Structuring My Text-Editing Program

I want to make a small command-line-run program that looks for a word or phrase in a target .txt. or .docx file, prints out a corresponding blurb about that phrase, and then replaces it with a ...
1
vote
2answers
199 views

State Design Pattern

I've come across the following State Design Pattern which seems extremely logical and simple to implement: class CeilingFanPullChain { private State m_current_state; public ...
-1
votes
5answers
186 views

Finally block when no exceptions thrown

I'm doing some cleanup operations that could throw an exception, and I want to implement the logic of a finally block, but only if no exceptions are thrown: The initial implementation is this: ...
1
vote
1answer
55 views

Coding guidlines for Controller and Dao?

My Controller code: ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ObjectReader objectReader = objectMapper.reader(...
0
votes
1answer
43 views

Removing constraints of Java array

Java arrays only allow subscripts to range between 0 and N-1 for an array of size N. The class below aims to remove that constraint by allowing the class user to specify the valid subscripts ...
1
vote
2answers
105 views

Adding properties to exceptions

Is it wrong to add fields to exceptions? I have a problem that happens and I'm thinking of adding considerable information to an exception, but it sounds weird: an exception with getters. What you ...
0
votes
0answers
24 views

Providing an API for Cancel(QueryID) i.e. Cancelling a long running query through JDBC in RESTful service

We went through few blogs on internet, which suggested to use Statement.close() method. Our scenario : We have developed RESTful service. We execute an SQL query through JDBC framework behind an API ...
6
votes
3answers
587 views

Is it better to expose or hide dependency in OOP?

Let's say I have an object A, which is too big(having too many methods and variables). So, I break it down to smaller objects. After that, I have Object A, B, and C. Obviously, Object A is from Class ...
2
votes
1answer
47 views

Memory allocation while calling a sequence of functions in Java

A method getReminder takes two integers and returns r = (a^5)%m. This method relies in two BigInteger numbers BigInteger.valueOf(a).pow(5) and BigInteger.valueOf(m), but BigInteger was never declared....
2
votes
2answers
187 views

Why does the development team of IntelliJ IDEA‎ store its dependencies as jars (e.g. JUnit) inside their cvs?

The very popular IntelliJ IDEA‎ has currently saved a lot of dependencies as actual jar files in their git repository e.g.JUnit, which I don't understand. Build tools like Maven provide excellent ...
-1
votes
2answers
162 views

Is main() function better on top of all other functions? [closed]

My college professor told me that main functions should be defined on top of other function definitions. We should use a forward declaration in order to accomplish this (we use C at that time). So yes,...
1
vote
2answers
159 views

Structure of RESTful Service with Java Spring for Beginner

I am relatively new in terms of Java web development skills. I have a project that I think would make a good candidate for a RESTful service from what little I understand about APIs. I'm trying to get ...
0
votes
2answers
122 views

Where/how to store program data?

This may be more of a software design question - but I've been working on my first "real, non-academic" Java project and have recently learned about good code practices (such as breaking down methods ...
0
votes
0answers
39 views

coming from java to nodejs whats the convention for error handling logging? e.message or e.stack?

I come from java, when I got an expected error I printed stack traces. I'm coming now to work on nodejs (never really worked on javascript). and in the nodejs project which I need to maintain (...
-3
votes
2answers
43 views

ArrayList Dynamic remove and add for socker client [closed]

I have one ArrayList in Java and a save the socket and one unique id. When someone client is add in the ArrayList, the unique id i have is NOT the same with position in ArrayList. When someone ...
1
vote
1answer
53 views

Distributing an application in 2 or more servers

This is probably a common question and I've been reading a lot about this, but I can't look into a solution. Let's say I have an enterprise application in one glassfish server located in New York. ...
4
votes
2answers
177 views

Distinguish different type of Comments

I would like to provide design decisions in the comments as well. I want design decision comments to be distinguishable from function contract comments, on cursory examination of source code. How to ...
0
votes
1answer
176 views

Business logic - Server side vs client side [duplicate]

In my current project, I have a screen which pulls data from several webservices, pulls data from database via backend API and checks that all resources have the same data or not. The other ...
2
votes
1answer
165 views

When to lock an object in a game

I'm writing a game in Java where each game object has a number of properties, but these can all be changed in one of two ways: Every second, a tick runs which may automatically cause a change. Users ...
1
vote
1answer
68 views

Software architecture for uploading dynamically created websites

I have a question that is crucial for my end of year project. Background My web application allows users to build other webapps based on drag&drop (within the domain of the webapp). These ...
0
votes
1answer
119 views

How to name this class? Is it a pattern?

I need to create a class which will have the following structure: public class MyClass { ArrayList<File> myList = new ArrayList<>(); public void addFile(File f) { myList....
1
vote
1answer
60 views

jersey post with a huge payload

I have a requirement to write a POST endpoint where the payload is huge(not normal). In the order 10s of Megabytes. And this endpoint will be accessed by a lot of clients (in the order of 1000s) ...
2
votes
1answer
59 views

Maven Build Lifecycle: validate

In the build lifecycle in maven, I encountered the validate phase described as validate the project is correct and all necessary information is available to complete a build 1. what are the check ...
1
vote
1answer
136 views

What are the significant memory management models aside from Java (GC) and C++ (manual approach)? [closed]

There are at least two distinct memory management models: Java (we do it for you) C++ (it is your responsibility) I have two questions: (1) Is GC language specific or compiler specific? (2) Do ...
1
vote
1answer
59 views

What is the recommended way to handle exception in Spring MVC

I have a Spring application, where we make few service calls to fetch data. There is a Data Layer in between the Controller and the Service layers. Controller (Request-Mapping) -> Data Layer -> ...
5
votes
3answers
624 views

Is it a good practice to use suppress warnings in your code?

I use @SuppressWarnings("unchecked") and @SuppressWarnings("null") mostly above methods to let the code compile without any warnings but I have my doubts. Found this Stackoverflow question. Jon Skeet ...
-1
votes
1answer
101 views

How to design property files

I always wonder what is the best way to design your property files. I have few questions that I didn't find an answer to them Do we place all our labels / error messages in one file? Do we split the ...
0
votes
2answers
70 views

Many instances of application, or single application with many threads?

I'm developing a Java application that will handle huge XML files (up to 300mb each and hundreds of thousands of lines). They are grouped usually with 20 to 40 similar XML files that also need ...
0
votes
0answers
26 views

The best implementation for fromJson factory method and json-mappings with inheritance?

I have BaseComponent (with field "type") and it's subclasses TextComponent, ListComponent, etc. Some of them has same fields. I want to create them and init their fields from json. Some of possible ...
0
votes
1answer
42 views

How to deal with automatic binding exceptions with Jersey?

It's really nice to have automatic binding with Jersey-Jackson (well, I believe it's actually MOXy the one who manages the bindings), so object serialization and deserialization is done under the hood....
2
votes
2answers
163 views

Should I return a 204 or a 404 response when a resource is not found?

I am developing a simple RESTful service for tournaments and schedules. When a tournament is created through a POST request containing a JSON body, the tournament is inserted in a BiMap, declared as ...
9
votes
3answers
270 views

Why does java.time have methods for creating objects instead of just constructors?

In the new java.time package the core classes are using the factory method of instead of a public constructor. Even though I like the cosmetics of the of method I can't see a good reason to not use a ...
0
votes
1answer
95 views

Divide java web app into smaller web app

I've a web application that consists of 3 main technologies: JSF, jax-rs and websocket. All three are coupled together with the help of CDI injection and JPA. That means that when a user login, he ...
2
votes
2answers
115 views

Data structure to hold Excel column names with their values

I am learning how to read Excel workbooks in Java and want to know what a good Data Structure will be for holding Column names with the values under them. Example: I want to be able to call a ...
0
votes
1answer
131 views

Using database connection on multiple threads

let's say I have a database connection in the class Database which offers the following public methods public synchronized void open() {} public synchronized void close() {} public synchronized void ...
1
vote
2answers
180 views

What is the role of “throws exeption” in method definition in Java?

Some methods are deciared this way: public int myMethod() throws Exception { (return an int or throw Exception if method fails). However, stub methods in NetBeans look like public class JavaApp { ...
1
vote
1answer
145 views

what is this kind of object creation?

final CyclicBarrier cb = new CyclicBarrier(value,new Runnable(){ public void run(){ ...statements } }); suppose you have a cyclic barrier in which one of the the arguments is the direct ...