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
votes
0answers
50 views

Create an OS X Executable from a Windows Machine?

Okay so I made a small java game and packaged it into an .exe and it works just fine... for Windows users. My friends with Unix based systems can't launch the executable so I'm wondering how can I ...
-5
votes
0answers
40 views

How should I quote for small software project? [on hold]

I am asked to provide a proposal and quote for a small software project. The project will be done in Java. The details are 100 questions grouped into 4 groups with 10-30 questions per group. The ...
-2
votes
0answers
55 views

Where will object declared as local variable reside in stack or heap?

In java I have heard that object resides in heap memory and local variables reside in stack. Objects created and referenced in a function is local to function rite? Where will that go to. class ...
0
votes
0answers
45 views

Find fastest connection to a certain point

What i'm trying to implement is a program that is searching for the fastest connection from one station to other at a given time of the day. I have a number of stations n, and a number m of lines ...
-1
votes
1answer
51 views

Alert when size of continuous stream of events exceeds 1000

A friend of mine was recently asked this question in an interview. Lets say there is a continuous stream of incoming events E1, E2 each with timestamp of entry associated with them. Write a java ...
1
vote
1answer
92 views

Getting started with machine learning a zero sum game?

I have a simple zero sum, discrete, deterministic, complete information board game. I want to machine learn an evaluation function for an AI agent. Suppose each board state has ~20 identifiable ...
0
votes
0answers
61 views

Algorithm to fit all items in a bag choosing most optimal cost?

Is there any algorithm to do this? I have objects that have attributes, maybe some weight, type, etc. I need to place the best configurations possibles where all my objects no matter the type fit, ...
15
votes
5answers
1k views

Why would a type be coupled with its builder?

I've recently deleted a java answer of mine on Code Review, that started like this: private Person(PersonBuilder builder) { Stop. Red flag. A PersonBuilder would build a Person; it knows about ...
-4
votes
2answers
42 views

Cache repository violating the SRP

interface IRepository { Data getData(); } class BaseRepository implements IRepository { public Data getData() { ... } } class CacheRepository implements IRepository { private final ...
-5
votes
0answers
88 views

Why is JSF very complicated?

I'm just trying to create a simple web application that can retrieve information from a database and display them, but to populate a drop down list with complex objects is just a full-time job itself. ...
-2
votes
2answers
89 views

How to mount a virtual drive?

I wondered if it is possible to mount a virtual drive (file) with Java. I saw that before in Truecrypt. So is it possible with Java? And how can I achieve that?
30
votes
5answers
3k views

When should I extend a Java Swing class?

My current understanding of Inheritance implementation is that one should only extend a class if an IS-A relation is present. If the parent class can further have more specific child types with ...
-3
votes
0answers
49 views

Java Certification exam materials and objectives [on hold]

Iam preparing for java certification exam using this tutorial site http://www.javaprepare.com/java-questions/ please suggest me some books regarding java certification..
0
votes
1answer
54 views

What is the proper or recommended way to save String[]'s, Array's, ArrayList's and int[]'s to Android?

I've looked up this question many many times but keep seeing different answers, what is the BEST way to save array's? It seems ludicrously infantile that there is no standard or easy way to save ...
1
vote
1answer
81 views

Sharing POJO between different handlers

I am trying to automate Business Process which can be characterized as a pipeline with distinct stages. Pipeline can be perceived as A->B->C, where A,B,C are distinct Business Steps that ...
3
votes
1answer
54 views

Is there use case for implementing a callback if a future is returned?

If I have function which returns a future, is there any reason to also include a callback where the callback is simply called right before the future completes? The only advantage I can think of ...
7
votes
5answers
354 views

Inheritance vs additional property with null value

For classes with optional fields, is it better to use inheritance or a nullable property? Consider this example: class Book { private String name; } class BookWithColor extends Book { private ...
-3
votes
0answers
9 views

need to find the index at p percent of the array length, and return all the values before that index point [migrated]

given an int[] x and a perentage p (0 - 100), find the smallest valued element y of x so that at least percentage p elements of x are less than or equal to y. I have code that sorts the array ...
-6
votes
0answers
61 views

Help me in this java programs [on hold]

Write a program: Must start if user says hello Has to repeat until the user says bye Ask user to enter his or her name, let him or her know if the entered name contains space or dot. Each time print ...
-2
votes
1answer
129 views

Shouldn't Java method parameters always be final [on hold]

Say I have a method that writes a string to a file: public void write(String content, File out) { // writes content to out } If I want to protect the parameters and ensure that they are not ...
0
votes
2answers
73 views

Creating a Vector (physics) Class in Java

I'm trying to create a vector (like in physics) class in Java. I want to support vector addition, dot product, scalar multiplication, etc. So, my question is, is it possible to do this with generics? ...
2
votes
2answers
60 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 ...
-4
votes
0answers
24 views

Registration servlet issue (BLOB and DAO) in mysql [on hold]

I was trying to implement a registration page where I had profile image as a blob in the form. I tried to use a DAO to insert the form inputs to a mysql table 'users'. However this is not inserting ...
4
votes
1answer
96 views

What is the point of calculating these variables this way?

I'm skimming through a very popular game's source code at the moment and I came across these variables inside of this class. public static final BlockPos ORIGIN = new BlockPos(0, 0, 0); private ...
1
vote
1answer
39 views

How to use fields from an object after an exception is thrown and the object can't be fully created

The issue that I have is that I need information from an object that a method returns when it throws an exception. It is a little hard to describe so I have this java pseudo code example. I have a ...
-2
votes
0answers
26 views

How would I implement the following formula as a function in java? [closed]

Where you are trying to find the smallest number for n with inputs p and y. I tried to implement this as: int index = 0; for (int i = 0; index == 0; i++) { if (bFormula(i, perHit, hitsNeeded) ...
0
votes
1answer
43 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 ...
0
votes
1answer
51 views

Taskrunner - with multi threading design [on hold]

I am looking for advice on how to implement a multi threaded task runner. My background is Java and Spring. It would look like the following. BatchTask Each BatchTask shall run in parallel and ...
2
votes
1answer
52 views

Observer Design Pattern with complicated objects

I am trying to currently get a good grasp on the Observer design pattern, but I am stuck wondering about one specific issue. In the examples I have been able to find of implementation, they are all ...
0
votes
1answer
38 views

UML- Aggregation or Association

Below is the problem for which I have created a UML diagram with Staff as superclass and waiter, manager and hosts as subclasses, I understood other parts, except for the relation between table and ...
1
vote
2answers
51 views

Set data in multi-level objects (may be using Java Reflection)

I want to possibly use Java Reflection to set some data at RunTime. My problem is I can't figure out how do I get sub-classes information and use as a part of reflection. I want to use Reflection to ...
-1
votes
2answers
89 views

How to validate Exception messages? [closed]

My superior asked me to validate each and every input field in the project that includes the Exception messages. So, am I correct in using Exceptional Handler for validating Exception message. ...
25
votes
3answers
5k views

If I implement an Interface, is it called an Inheritance?

If my class implements an interface then can I say that I'm following inheritance? I know that when a class extends another class then it's inheritance.
0
votes
1answer
63 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 ...
-1
votes
0answers
31 views

How to extract edges using the standard deviation

I am currently creating a Content Based Image Retrieval system in Java. My algorithm currently computes the standard deviation (Based on RGB values). I am trying to build on that algorithm and make ...
0
votes
1answer
84 views

Are new empty Java marker interfaces created to satisfy an existing method contract a code smell?

Suppose I have a POJO A and some client code that serves it. I have created POJO B, which doesn't have anything in common with A, but I want to use it in the methods that use A, so I decided to create ...
75
votes
6answers
12k views

Why are floats still part of the Java language when doubles are mostly recommended instead?

In every place I've looked, it says that double is superior to float in almost every way. float has been made obsolete by double in Java, so why is it still used? I program a lot with Libgdx, and ...
2
votes
3answers
90 views

Logging an audit trail (Java application)

I'm creating a Java (Spring Boot) application for creating Entities. I've got my @Controller for getting the data from a web front end, I've got my @Service for processing the data, and I've got my ...
0
votes
1answer
62 views

Why is a Spring's HttpClientErrorException an unchecked exception?

Oracle summarises the purpose of unchecked exceptions as: The next question might be: "If it's so good to document a method's API, including the exceptions it can throw, why not specify runtime ...
2
votes
1answer
141 views

Checking preconditions the proper way

I have a class with around 1300 lines and it has many CRUD-like methods that need parameters to be checked, for some of them it's more than just a few rules. For clarity purposes, I am going to use ...
1
vote
0answers
16 views

How do I properly manage EntityManagerFactory and EntityManagers for long running tasks?

We're building a JavaFX application that connects to a remote Oracle database using EclipseLink on one end and a SOAP service on the other end. We're writing long running transactions that will pull ...
0
votes
1answer
67 views

Controller calling multiple services

I have a few layers in my WebApplication: Presentation, Service, DAO, Domain. Services call DAO objects which reads data from a Database/File whatever. I have a Controller that needs to fetch data ...
3
votes
1answer
158 views

Forward Slash vs Back Slash vs File.separator in Java

I've seen some programmers doing the following : File file = new File("folder\\subfolder\\subsubfolder"); And I find it totally wrong because of compatibility issues with a different OS than ...
1
vote
0answers
31 views

Why Does JavaFX's GridPane Attach Properties of the Layout to the Components?

I am currently learning JavaFX and I came across a very strange API for laying out GUI components. It is perhaps best explained by it's javadoc: To use the GridPane, an application needs to set ...
1
vote
1answer
68 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 ...
3
votes
4answers
154 views

How to name an exception where condition is not exceptional

NOTE: This question is about finding a proper name for an exception where the condition for throwing the exception has not actually happened (eg. preventing a StackOverflow by throwing a ...
9
votes
3answers
253 views

OOP design problem. Two kinds of empty Optional

I'm writing a quite simple application that deals with hotel rooms reservation. I've got a problem at one stage. I'm processing a queue of orders. For every order one of the receptionists should ...
3
votes
0answers
79 views

Finger Paint path gets huge over time and slows the app

So I am writing a Finger paint app. I have multiple color which user can select. I save the path and paint information inside an array. ArrayList<PaintPath> arrayPaintPath = new ...
8
votes
2answers
164 views

How to resolve LSP violation based on minimum precondition

I have a class Party that has a constructor that takes a Collection<Foo>. I plan to have two subclasses NpcParty and PlayerParty. All Party instances have an upper limit on the size of the input ...
1
vote
1answer
46 views

Redesigning a builder to make it reusable

Let's say I have a builder class (which by the way is not techinically a builder, but it's not a factory either) to generate different rules for a game: public class RuleBuilder { private Game ...