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
0answers
21 views

Java - Get Interface Generic Type

I'm trying to create an Interface with Generics which allows me to get the type of object in the generics but no matter what I try there's a syntax error. I've tried the following 3 methods. All of ...
12
votes
3answers
569 views

How does one keep argument counts low and still keep third party dependencies separate?

I use a third party library. They pass me a POJO that, for our intents and purposes, is probably implemented like this: public class OurData { private String foo; private String bar; private ...
-5
votes
0answers
13 views

Compare Values from two spinner and display the result accordingly in android studio [on hold]

I am developing an android app for bus routes in android studio. both spinner holds the cities names. I want to compare the values of both spinner(dropdown) and display the result i-e bus number for ...
-1
votes
0answers
20 views

Best way to get data from database inside Thread Class in Spring

Currently i am troubling that how to get data from database inside my thread class. I can't make bean of my thread class because new instance is created of thread on every request. MyThread.class ...
5
votes
2answers
376 views

When to fix something that is “wrong” but works fine

Short version: I wrote some code that is not done "the right way" because, when I wrote it, I didn't know how to do it. Now that I know how to do it "the right way", how do I decide how to fix it? ...
4
votes
2answers
206 views

Is it a good practice to burn business logic into Enums?

Let's have a simplified business logic like this: public enum BusinessLogic { STAGE_ONE(true, false, false), STAGE_TWO(true, true, false), STAGE_THREE(false, false, true); private final ...
0
votes
3answers
103 views

Should abstract classes be used to prevent instantiation

Is preventing the instantiation of a class a valid reason to make it abstract? For example, if I have a class called Gauge which has subclasses HeadingIndicator and AirSpeedIndicator, is it a good ...
-6
votes
0answers
42 views

How to compute days between two date choosers [on hold]

How to compute days between two date choosers and show it inside the textfield; is this correct and what is the code should i input inside the settext Date date1 = this.dcStart.getDate(); Date date2 ...
-2
votes
0answers
43 views

how to identify http requests made with a java app

I am an avid Go player and play on the Kiseido Go Server. The only client I know is the one app CGoban which operates in desktop Java (https://www.gokgs.com/download.jsp), or if you wish as a Java ...
0
votes
3answers
167 views

Why Double.parseDouble(“ABC”) not returns Double.NaN?

This code: Double.parseDouble("ABC") throws a NumberFormatException. Why is it wrong to expect a Double.NaN (NaN is literally Not-A-Number). A working example is this: public static void ...
-6
votes
1answer
70 views

Im a noob in programing and i tryed to create something like a rpg game can you tell me what you think about it and tell me if i can change anything [on hold]

import java.util.Scanner; public class JAva1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); float MAtP, MSpP, MCHit, MHP, MSpeed; ...
4
votes
1answer
254 views

Small code, big test

I have this code in a controller of an MVC implementation: public void execute() { try { String path = userSelectsFile(); if ( path == null ) return; //Just returns ...
0
votes
0answers
63 views

Best practices for programmatic describing of behavior of complex input forms

We have a complex web form (we use GWT/GXT stack) with lots of input elements of different types (text fields, selects, checkboxes, buttons), and behavior of these elements depends on each other. Now ...
-2
votes
0answers
23 views

Good tutorial for Atmosphere? [on hold]

What is your favorite tutorial for Atmosphere framework (async-io.org)? It's not much fun (for me, at least) trying to glue together atmosphere-examples and bits of info scattered through atmosphere ...
2
votes
5answers
688 views

Is it possible to make some methods invisible/non-usable to some classes in Java?

I am developing an application in Java whereby I would like to pass an object as part of an interface into other methods of classes written by other developers in the team. The object I'm passing in ...
1
vote
0answers
35 views

Java MVC: multiple use of the same event for different actions

I am working on a large Java project which employs the model-view-controller pattern. Should I use a different event for each action (to let the views communicate with their respective controllers)? ...
0
votes
1answer
42 views

Is there an established pattern for associating a database entry with a Java class that executes on that data?

I have a behavior tree with different leaf nodes that execute tasks. When building out the tree relationship in the database I need an association between the leaf node entry and the Java class that ...
0
votes
1answer
37 views

Architecture question about data migration

I'm facing a new enterprise project in Java about data migration. I did one of them in the past, now I want to do a better work and I think I need your considerations. So, let's me explain the ...
-4
votes
0answers
25 views

Cross platform application framework [closed]

I am planning to develop a cross platform application that will run on all operating systems mainly windows desktop, Mac desktop, android and Apple mobile devices. What are the cross platform ...
-4
votes
0answers
38 views

I want to switch my programming platform [closed]

I have worked as a ASP.NET developer(Web) for 4 years and I waked on Desktop applications as well(WPF). As everyone knows many things are taken care by .net framework and by Visual Studios, as days ...
-3
votes
1answer
40 views

How should I change in get method without calling getList() of Deque? [closed]

import java.util.List; import java.util.ArrayList; public class Test { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { ...
1
vote
2answers
116 views

Is it better to perform a calculation in the field's setter or have a different method?

I'm implementing a simple Quota object which determines a usage percentage based on the maximum and the used. private int maximum; private int used; public Quota(int used, int maximum) { ...
0
votes
1answer
97 views

Enum as singleton or fully functional class [duplicate]

Joshua Bloch claims that "a single-element enumeration type is the best way to implement a singleton" Why? I totally disagree with this statement because enumeration is data type with some ...
-2
votes
0answers
37 views

Design pattern for Login Online and offline [closed]

I am new to Software Design patterns, I am developing an application in which user may liggedin offline or online depending on internet connectivity... so which design pattern will be best solution ...
-3
votes
0answers
27 views

Suggestions for Subscription-Based Software Product Licensing [closed]

Can anyone suggest some solutions or products for doing subscription-based software product licensing? We have used dongle-based solutions in the past but, with the proliferation of virtualization, ...
-1
votes
0answers
37 views

Advice needed on Selecting Server VS Cloud [closed]

I am having a big issue. Imagine that I am planning to launch a local social media site. You know what it is, multiple users, lot of data uploads (ie: photos, notes, etc). However I am having a hard ...
-1
votes
0answers
19 views

How BeanPropertyRowMapper works internally in spring?

I know that BeanPropertyRowmapper use setter method when I fire select query but is it uses getter method too or not ? I don't want to make my custom row mapper or hibernate or JPA. I have face below ...
-4
votes
0answers
49 views

About primitive types in java [duplicate]

I see that Java has Boolean (class) vs boolean (primitive). Likewise, there's an Integer (class) vs int (primitive). What's the best practice on when to use the primitive version vs the class? Should ...
-2
votes
0answers
49 views

Java : Error: A JNI error has occurred, please check your installation and try again [closed]

I am trying to run a new application which requires Java (Kaazing) and keep getting this error on startup "Error: A JNI error has occurred, please check your installation and try again" I have ...
0
votes
1answer
109 views

Should I use one class that calls Several static methods or several classes each calling one static method

I need to use instances which represent mathematical functions along with their parameters end enable their evaluation. I can take 2 approaches: 1: have a single class representing all the math ...
1
vote
0answers
29 views

Individual methods or parameters for Google Analytics abstraction on Android

A coworker and I are having a discussion around the best way to build our abstraction on top of Google Analytics for an Android application. A couple of data points. We have auto-tracking enabled ...
1
vote
0answers
91 views

Finding ArrayList elements in ArrayList [migrated]

I have two ArrayList userActions and actionsToCheck of type enum Action. I want to check if all the elements in actionsToCheck is present in userActions. Is the following good enough or is there a ...
-4
votes
2answers
102 views

it is possible to implement keyloggers in java [closed]

I am researching on keyloggers and as a part of my research I would like to know if its possible to implement keyloggers in java edit * How can i create a keylogger in java or to be precise what ...
1
vote
2answers
145 views

How to add rigor to my testing?

I work on a small/medium sized Java application. Over time, I've tried to ensure that the tests which I write are "good" tests, and that there's plenty of them. Hence I've been looking into various, ...
0
votes
2answers
102 views

Printing to out vs Logging, given the nature of this app?

I'm writing a command line application in Java. That app will scan a list of remote resources, do several attempts to access those resources, report failed attempts, and if succesfully accesed, ...
0
votes
1answer
105 views

Implementing a NoSQL and RDBMS compatible DAO

What would be the correct way to design a DAO which implementation is first going to be targeting a MS SQL database with a STAR model, but yet, business requirements specify the application must be ...
0
votes
2answers
73 views

Classic ASP to Java UI Conversion

My question is based on a business model of a financial services organization that currently is supporting applications that are a hybrid mix of Classic ASP and Java, with some JSP’s already in some ...
0
votes
2answers
103 views

Saving to file before storing into a database in a REST service

A mobile back-end I am building should receive a larger amount of data (some sensor recordings) from an Android phone. The phone does not have much use of it so it was most efficient to store the data ...
1
vote
1answer
103 views

Automatic Type Promotion in JAVA

I have started studying JAVA . In there, byte ch=50; ch*=2; works fine. But byte ch=50; ch=ch*2; does not. error:possible loss of precision required:byte found:int Why this do not happen ...
13
votes
7answers
2k views

Is there a pattern for a more “natural” way of adding items to collections? [closed]

I think the most common way of adding something to a collection is to use some kind of Add method that a collection provides: class Item {} var items = new List<Item>(); items.Add(new ...
1
vote
4answers
161 views

Options for constructing an object that is not logically initialized until all fields are set

I am working on a Pokemon game at the moment, and am running into some design concerns. The easiest example is as follows: Each Species of Pokemon has several traits that are required before it is ...
3
votes
3answers
475 views

Should I try it straight or should I first check if it can be done?

I have a set of items, and each item in the set must be unique. Item are composed from multiple properties and each property of each item can be changed. But after each change every item in the set ...
1
vote
2answers
88 views

Java applets with Safari on Windows as compared to Safari on OS X [on hold]

I have a developed an Applet which works fine on Chrome/IE/FF on Windows. I am not expecting any users for Safari on Windows but there might be the odd user who may be on a Mac. As of now, I don't ...
3
votes
4answers
364 views

Are `switch` statements generally used wrong? [closed]

I see most developers using switch statements with breaks in each and every case. Is this usage of switch statements inappropriate since a simple set of if-else statements would suffice? Is it OK for ...
0
votes
1answer
95 views

How to make my program do something when an errors pops up instead of crashing?

Basically i'm writing a game in Java where i want the program to tell the user that he can't move right or left if that move will cause the player to move out of the array, which means this: ...
0
votes
3answers
131 views

Should I be extracting strings from source in core java the way android does?

I just started doing android development stuff after getting pretty comfortable with Java. Android apps tend to do this weird thing where they have all strings for their program held in an XML file ...
-1
votes
0answers
28 views

Problem in Javafx: Pane actions are mirrored on other panes [migrated]

I've recently been trying to create a small 2D physics sim using javafx. Ive created a new class Entity the extends Pane. After adding all the entities to the game engine, I found that if i tried to ...
0
votes
0answers
47 views

Tic-Tac-Toe Java : Button Issues [migrated]

I've created a little TicTacToe game in Java and I figured to write more effcient code, I'd make a for loop to create the 9 buttons. The issue I'm having is figuring out how to test now which button ...
0
votes
1answer
100 views

ActiveRecord equivalent in Java [closed]

My question is fairly simple.. What is the closest ORM to ActiveRecord that I'd be able to find for Java? In other words, in terms of thinking patterns and knowledge, with limted development time, ...
2
votes
3answers
150 views

Good or bad idea to create a “fromJSON” static factory constructor for an object that is often created by parsing a JSON coming from API?

I have a "Product" POJO class in my app. A Product object can either be created in-app by the user or by parsing a json that comes from the API. Product has 20+ fields, but Im using only 2 here for ...