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

Is JBPM the right tool for this? [closed]

We have a utility for monitoring directories and taking actions when files appear in those directories. It's in java and takes the form of a standalone jar which launches several threads when started: ...
0
votes
3answers
204 views

Java Serialization for long-ish-term storage

I have an application that uses a database of about 15,000 Java objects, which I have to read every time the application starts. Originally I've been using JSON to store the data, but that has a few ...
5
votes
2answers
510 views

Why does java collections not supply a function for the index of max value?

I have been using Collections.max(list) for many projects, but I occasionally want to find the index of that maximum element. I feel silly writing a function to do this for myself in every program I ...
4
votes
2answers
224 views

@SuppressWarnings in coding test submission

I am working on a coding test for an employer. It is not a particularly hard question but I am trying to do it as well and technically correctly as possible for obvious reasons. I ran into a problem ...
3
votes
2answers
428 views

How does the JVM handle an exception thrown by the main method?

I understand exceptions, throwing them, handling them, and propagating them to a method lower in the call stack (i.e. throws). What I don't understand is this: public static void main(String[] args) ...
0
votes
2answers
129 views

Is there a way for Object 1 to call Object 2's enums in a function call?

For example, if I have two classes "Director" and "Follower". I want the Director to tell the follower where to go (ex: follower1.go(direction.LEFT)), and I want the Director to know what directions ...
1
vote
1answer
183 views

Divide and Conquer Algorithm clarification needed

I have a homework assignment for a data structure/algorithm class. The task is to take an unsorted array of size n (example: [-8, 3, 2, -3, 3, 1, -3, -5]), and we have to use a divide and conquer ...
0
votes
1answer
153 views

Act as MySQL server in Java/Android [closed]

Is it possible to act as a MySQL server in a Java or Android application, such that applications like HeidiSQL can connect to it? What I want to do is to write an application for Android which ...
2
votes
1answer
290 views

Converting cron schedule to time intervals

I have, on the server, many jobs defined by users and some of those jobs are scheduled using cron expressions. I need to check (I can execute Groovy/Java on the server) if those jobs take longer than ...
1
vote
2answers
256 views

When should I refactor a private class into a package-private class?

When I began implementing a class in my system (let's call it A), I realized I needed some kind of object that does something. So I needed a new class (let's call it B), but I made it a private static ...
-1
votes
1answer
133 views

Is it common to have a constructor with 7 elements for example? [duplicate]

Is it common to have a constructor with 7 elements for example? or is it better to use many setters instead?
1
vote
1answer
110 views

Java Modal Object Design

This question is not about a specific program. This is about design - the UML phase of the project. I am supervising a Java project. It will contain a lot of modal popup dialogs. From a C/C++ ...
1
vote
1answer
259 views

When creating a library, is there a way to make certain classes entirely internal to the library, and not exposed to the user of the library? [duplicate]

Suppose you were designing a Java library for other people to use. You compile the library into a JAR that they can import into their projects and use. Needless to say, you intend for the library to ...
1
vote
4answers
415 views

How to work around Java's lack of pointers to pointers when working with linked data structures? [closed]

I've learned from a textbook how to implement binary search trees recursively in Java, and am working on implementing them nonrecursively. I've found a simple and elegant way to implement an insert ...
0
votes
1answer
222 views

When should a class be final? [duplicate]

I've only really seen this on Java's wrapper classes (String, Integer, etc.), but never in open-source projects, and I was never taught about it in any books or classes. I know it means the class ...
3
votes
2answers
364 views

Best approach for multilingual Java Enum

I'm running into issues with an approach I am taking and am now wondering if I just started down the wrong path and should rethink my approach. Here is what I attempting. I would like to use an Enum ...
1
vote
2answers
193 views

When I create an object, is fresh memory allocated to both instance fields and methods or only to instance fields

I have a following class class Student{ int rollNumber; int marks; public void setResult(int rollNumber, int marks){ this.rollNumber=rollNumber; this.marks=marks; } public void ...
-2
votes
1answer
133 views

JAX-RS and application wide business logic/resources. My brick wall has be found [closed]

I think I'm definitely hitting a brick-wall in understanding how to implement this. I would very much appreciate any assistance in this. All my JAX-RS links, Oracle, IBM and Stack overflow links ...
11
votes
4answers
693 views

Is it an overkill to wrap a collection in a simple class only for the sake of better readability?

I have the following map: Map<Double, List<SoundEvent>> soundEventCells = new HashMap<Double, List<SoundEvent>>(); This HashMap maps double values (which are points in time) ...
0
votes
0answers
135 views

Do thin fluent builder method chains have any need to be “extensible”?

In an environment where refactoring is difficult extensibility can be a life saver. However, this is no excuse to over engineer code. Given that a thin fluent builder method chain is backed by well ...
0
votes
2answers
804 views

How to connect Android App to MongoDB deployed on Google Cloud

Currently I am working on a simple app which will be able to connect to MongoDB which is deployed in Google Cloud. I have set it up MongoDB ocaly on my computer and I have made a little JAVA console ...
2
votes
3answers
135 views

Proper interface for calculator library?

As practice, I'm planning to implement a multivariable calculator library. The idea is that you can define a function, such as f(x, y) = sin(x)^2 + 3*y^3, and then you can evaluate it with specific ...
0
votes
2answers
245 views

Organizing code in a 2 man team

I've been working with a buddy of mine on a school project. We forecast it'll take ~2 months, so it isn't a small scale project at all. Communication and splitting the work effectively has been a ...
0
votes
0answers
48 views

Mixing newable and injectable in a Callable

I recently read http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/ which discussed newable vs injectable objects. What would you do if you needed to make a Callable that talks to some service ...
1
vote
2answers
218 views

Java Desktop Application Requirement - Is sockets the preferred choice ?

I'm currently working on a requirement for a desktop application - using Java If for some reason the GUI crashes, it shouldn't affect the background process. Once the GUI is restarted - the ...
0
votes
0answers
116 views

How far to go when future proofing fluent-method-chained-DSL test code?

Is it worth implementing interfaces, or using the getThis() trick, or even static factory methods to future proof against the need to extend this DSL? The current design is a pair of thin ...
3
votes
2answers
136 views

To subclass or to wrap for “default” implementation?

I'm creating a toolset in Java consisting of many Natural Language Processing (NLP) tools, such as Tokenizer, POS tagger, Lemmatizer, Sentence parsing, etc. I want to put all good and publicly ...
1
vote
0answers
95 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 ...
1
vote
1answer
161 views

Do you use static keyword to declare single instance pattern? [duplicate]

I just come across this code and find it interesting to know whether you consider this as another single instance pattern? public class Initiator { private static String str; // there is many ...
0
votes
1answer
216 views

How is a floating point number represented in Java?

Which algorithm does java uses to convert floating point number (Ex:0.15625) into binary(0.00101)? Whether java uses normalized form or denormalized format? If I type float ab=0.15625 in Java source ...
1
vote
2answers
109 views

Changing message without redeploying / restarting application

Question: In java application, How to change error message or simple alert text without redeploying / restarting application Closest answers I could think up (1) is to have a new error messages in ...
-2
votes
1answer
169 views

What is the largest size a HashSet or TreeSet be? [closed]

So I am working on a solo project that involves a lot of strings. In one of my smaller test cases there will be at least 70 million elements. So my question is, what is the largest possible size a ...
2
votes
3answers
271 views

Could the creation of many methods in Java affect performance? [closed]

I was told by a colleague that in Java, the performance may be worse if we create more methods, stacking many methods calling over them in JVM, specially in a Java EE environment. This seems to ...
6
votes
2answers
502 views

Which is a better pattern (coding style) for validating arguments - hurdle (barrier) or fence? [duplicate]

I don't know if there are any accepted names for these patterns (or anti-patterns), but I like to call them what I call them here. Actually, that would be Question 1: What are accepted names for these ...
2
votes
1answer
264 views

What is the advantage of using Direct Web Remoting over a REST web services design? [closed]

I have an enterprise Java web application deployed in tomcat. I am looking for ways to integrate a HTML & JS UI with the mid tier java code. So far, looking around I have found that there are two ...
2
votes
1answer
164 views

DataMapper for a MMO game plugin to send packets

I am working on an plugin for some game-server. The information about the plugin is not really necessary. Few points you might find helpful to answer to this question: The server The server is ...
0
votes
5answers
370 views

Liskov Substitution and SRP Principle violation - how best to structure this scenario?

While learning SRP and LSP, I'm trying to improve the design of my code to comply best with both of these principles. I have an employee class that has a calculatePay method on it. Firstly, I believe ...
0
votes
1answer
124 views

Simple unicode application?

I want to create simple language learning applications to help friends in learning languages. A simple Java console application would do the trick, but the Windows console does not seem to handle ...
-3
votes
1answer
130 views

How valid is the statement “write once, debug everywhere” by some Java users? [duplicate]

How valid is the statement "write once, debug everywhere" by some Java users? If it is true, what is the effect to us?
1
vote
3answers
154 views

Null checking whilst navigating object hierarchies

I had to implement some code which traversed a small object hierarchy to fetch a value and display it in a TextView object (this is Android / Java). I had to do this 6 times to populate 6 TextViews ...
2
votes
2answers
131 views

Recreating files from shell script or java?

I have java application which takes a file, which is created by a process running on terminal. I start the process using a small shell script. Then run the Java application and it reads the file ...
2
votes
1answer
236 views

Any OOP design pattern that is somewhat representative of all of the SOLID OOP design principles at play?

I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one ...
0
votes
0answers
48 views

Apache Wicket, updating data without using a form, is it safe?

I have a ListUser.java class with a datatable, displaying UserData information, displays 4 columns, the last column is an AbstractColumn that has on it's populateItm method has added a inner class ...
0
votes
2answers
113 views

Logging Exception in multi-tier application

I'm building a multi-tier enterprise application using Spring. I have different layers: Controller, Business and Provider. Within the application I've built a custom error handling mini-framework that ...
2
votes
2answers
108 views

Static Test-Data in Helper Class: Getter vs Public Constant

Currently I am in process of writing large batches of Unit-Tests in the Project I am working on. Additionally we recently Introduced GUI-Testing. This project is a relatively simple webapp, on basis ...
4
votes
1answer
134 views

Java application structure: Horizontal vs vertical split

Having a bit of a debate about the starting project structure (using Maven/Eclipse) for a big Java application. Option 1: entities (i.e. the whole database using Hibernate classes-first) services ...
-1
votes
1answer
276 views

optimise my solution

I just solve this but want know more efficient way to do matrix multiplication M : ------ 1 1 0 0 0 5 3 2 0 f[n] = M^n I have implemented using Exponentiation_by_squaring Is there more ...
2
votes
1answer
275 views

Benefits of Java ByteArrayInputStream vs byte array?

I have a scenario where my Java process will be receiving a stream of binary data: public class DataHandler { public void handleData(DATA data) { // TODO: Do something with data } } ...
1
vote
0answers
130 views

Large Scale Application Development in Android

Since, I am fairly new to large scale app development in Android and Java, I though I would ask for your advice guys. My team was faced with developing a prototype of a fairly complex medical ...
1
vote
2answers
144 views

How to let the outside world decorate my private field?

Imagine a simple Controller (as in process control) interface. I have some concrete classes, say PIDController, that implement it. I also have some decorator classes that extend these classes ...