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
4 views

Return message to Android client from java Server via tcp sockets [migrated]

I am a beginner in Android with intermediate Java programming skills. I am also just learning socket communication. I am trying to make a very simple client/server connection. I have Android app as a ...
1
vote
2answers
49 views

Why can we use the same name for local variable in different scopes?

I was wondering why is it possible that we can use the same name for local variable in different scopes? Like we can have two methods which both can have variable with the same name. What makes ...
1
vote
3answers
33 views

Java logging dependency for a low-level library

I inherited a lower-level open source Java network library. The library is intended to be used by higher-level application protocol libraries which are in turn used by application code. My library, ...
0
votes
1answer
38 views

Use JSON objects or POJOs in back end service?

I'm building a back end service for mobile clients. The requirement is that the mobile clients will pass me a token, I'll use that token to talk to other systems (behind the company firewall) in my ...
-4
votes
0answers
24 views

How can I use two or more threads using same run method work on different arrays? [on hold]

I am working on a game that requires the 2 players to control the movement with same run method using multithreading...now i can draw the two different object separately(not overlapping) but cannot ...
-4
votes
0answers
40 views

Why 1 bytes has 8 bits? [duplicate]

Past time Latin language was used in computer for giving command ,Latin language has 256 characters,for represent 256 word 8 bits was used . 2^8=256 8 bits are enough for representing 256 character . ...
0
votes
0answers
46 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
5answers
1k 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
24 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
21 views

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

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
407 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
216 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
105 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
49 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 ...
-1
votes
0answers
59 views

How to identify http requests made from a closed-source java app?

I am an avid Go player and play on the Kiseido Go Server. I would like to write an open source client for this, but the KGS protocol is a well-kept secret. Is there any way to catch the http ...
0
votes
3answers
169 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
74 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
257 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
65 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
24 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
694 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
40 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
43 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
41 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
120 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
98 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 ...
-1
votes
0answers
20 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 ...
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
103 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
105 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
104 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
89 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
367 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
132 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 ...