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

-3
votes
1answer
77 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
121 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
0answers
13 views

Java GUI with JFrames [migrated]

Today I started learning Java GUI and tried to create a simple window on my Ubuntu. I am using jre7 for now. I wrote code exactly from tutorial because from experience there are stuff that doesn't ...
2
votes
2answers
107 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
0answers
34 views

How to connect a Django app with a Java Web app using JMS

I'm dealing with my DB systems course project, it's a stock exchange simulation app using Oracle 10g, the deal is that the support is for Java, but i'm going to do this in Python. The last iteration ...
2
votes
1answer
198 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
18 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
69 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
79 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 ...
-1
votes
1answer
270 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
159 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
92 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 ...
-2
votes
0answers
13 views

UnmarshalException while consuming a web service [migrated]

I have a web service based on a number of entity classes. one of them is shows below @Entity @Table(name = "users") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Users.findAll", query = "SELECT ...
1
vote
2answers
135 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 ...
2
votes
2answers
179 views

Parameterized Java Types (Generics)

Consider this "legacy" code: public interface IPersistentCollection { IPersistentCollection cons(Object o); } Genericized in Java, it could become something like this: public interface ...
0
votes
2answers
163 views

Handling multiple packet types in Java 8

I have a Netty-based game server implementation that handles 40 or so distinct packets with their own serialization structure, for brevity I'll refer to them as FooPacket, BarPacket, ... These packet ...
1
vote
1answer
45 views

Using Mockito.reset

I've just read a lot of arguments against using Mockito.reset and can't make much sense of it. Put differently, I agree in general, but there's always a case which looks like using reset is useful or ...
0
votes
3answers
124 views

How should be the approach to start thinking about multi thread programming [closed]

I am an experienced java developer.Of now I have started learning multithreading in java.I am able to grasp most of the concepts but still I am unable to visualize applications running on threads.I ...
1
vote
1answer
90 views

Why is Throwable initCause designed to be called only once?

I find it really odd that the initCause method of Java's Throwable class can only be called once, or even not at all (if the constructor accepting a Throwable was used). This makes exception chaining ...
0
votes
2answers
72 views

C++ Data Server and J2ME client communication [closed]

I am working on a robot that has some AI built in. However, the mandated robot controller does not have the power to do the work onboard. This means that I need to use a co-processor. I am writing ...
1
vote
2answers
214 views

Java: how can I make the return type, of an inherited method in a subclass, the same as the subclass?

I am rather inexperience in Java, and I'm having a problem in forming a subclass of a class I have created. The class I have made, called Vector2D, contains methods, such as add(Vector2D addend), that ...
0
votes
1answer
106 views

Ajax call or js to update a cart price

I am building a cart in Java and would like to give users the ability to update the quantity and see the new price instantly. I am using BigDecimal on the back-end for complete accuracy, but the ajax ...
-4
votes
1answer
106 views

Try and catch error trapping, why is it so significant? [duplicate]

I try to understand why should I "try" a method to catch errors. It looks to me like the concept is: "letting a process run assuming its not properly developed". Should I always assume that a ...
-1
votes
1answer
106 views

How to implement a genetic algorithm with distance, time, and cost [closed]

I want to make a solution to find the optimum route of school visit. For example, I want to visit 5 schools (A, B, C, D, E) in my city. Given the choice of five routes regarding what school I should ...
1
vote
1answer
128 views

What is the difference between Callback<T> and Java 8's Supplier<T>?

I've been switching over to Java from C# after some recommendations from some over at CodeReview. So, when I was looking into LWJGL, one thing I remembered was that every call to Display must be ...
2
votes
1answer
96 views

What do I have to do when using libraries with BSD license?

I am making a game using LWJGL and this is their license. What I don't understand is what must I do? I plan on making a game and distributing it, not the source code just the .jar file and maybe sell ...
18
votes
12answers
5k views

Why does void in C mean not void?

In strongly-typed languages like Java and C#, void (or Void) as a return type for a method seem to mean: This method doesn't return anything. Nothing. No return. You will not receive anything from ...
1
vote
2answers
151 views

Instantiating objects in Java [closed]

I'm learning now Java from scratch and when I started to learn about instantiating objects, I don't understand - in which cases do I need to instantiate objects? For example I'm studying from TutsPlus ...
1
vote
1answer
88 views

Tomcat + Spring + CI workflow [closed]

We're starting our very first project with Spring and java web stack. This project will be mainly about rewriting quite large ERP/CRM from Zend Framework to Java. Important factor in my question is ...
-2
votes
0answers
61 views

Maximum tcp port number constant in java [migrated]

Is there a public constant for the maximum TCP port number (65535) defined in java or a common library such as Apache Commons, that I could refer to from my code (instead of using the integer ...
1
vote
0answers
108 views

Embedded Tomcat Cluster

Can someone please explain with an example how an Embedded Tomcat Cluster works. Would a load balancer be necessary? Since we're using embedded tomcat, how would two separate jar files (each a ...
1
vote
2answers
154 views

If there's no problem treating a statement as an expression, why was there a distinction in the first place in some programming languages? [duplicate]

Why do we have the distinction between statements and expressions in most programming languages? For example, in Java, assuming f and g return ints, this still won't compile because it's a statement ...
1
vote
2answers
68 views

Need to organize words based on their components, any other way aside from brute force?

I'm not sure if this process has a name. I have some words (about 9,000). They are in Japanese, but I'll try to explain this using English words. I want to categorize the words by the components (in ...
0
votes
2answers
180 views

Can regexp be used to check for palindromes?

Can regexp pattern matching be used to check for palindromes within a given text in Java? My intuition is that in order to check for palindromes, we may need to remember the character that was ...
1
vote
2answers
45 views

Should I reference a CopyOnWriteArraySet from the Set interface?

There are two ways to use a CopyOnWriteArraySet: // A Set<Object> set = new CopyOnWriteArraySet<>(); and // B CopyOnWriteArraySet<Object> set = new CopyOnWriteArraySet<>(); ...
0
votes
1answer
72 views

Prepared statement alternatives for this middle-man program?

I have an program that is using a prepared statement to connect and write to a database working nicely, and now need to create a middle-man program to insert between this program and the database. ...
0
votes
1answer
140 views

API always returns JSONObject or JSONArray Best practices

I'm making an API that will return data in JSON. I also wanted on client side to make an utility class to call this API. Something like : JSONObject sendGetRequest(Url url); JSONObject ...
2
votes
3answers
215 views

Decoupling software components via naming convention

I'm currently evaluating alternatives to refactor a drivermanagement. In my multitier architecture I have Baseclass DAL.Device //my entity Interfaces BL.IDriver //handles the dataprocessing ...
4
votes
2answers
248 views

Does this factory method pattern example violate open-close?

In Head-First Design Patterns, they use a pizza shop example to demonstrate the factory method pattern. public abstract class PizzaStore { public Pizza orderPizza(String type) { Pizza pizza; ...
0
votes
2answers
108 views

How to avoid or minimise use of check/conditional statement in my scenario?

I have scenario, where I got stream and I need to check for some value. If I got any new value I have to store it in any of data structure. It seems very easy, I can place conditional statement ...
0
votes
3answers
137 views

How to change the state of a singleton in runtime

Consider I am going to write a simple file based logger AppLogger to be used in my apps, ideally it should be a singleton so I can call it via public class AppLogger { public static String file = ...
0
votes
2answers
111 views

API Class with intensive network requests

I'm working an API which works as "intermediary" between a REST API and the developer. In this way, when the programmer do something like this: User user = client.getUser(nickname); it will ...
1
vote
1answer
211 views

Implementation of instance testing in Java, C++, C#

For curiosity purposes as well as understanding what they entail in a program, I'm curious as to how instance testing (instanceof/is/using dynamic_cast in c++) works. I've tried to google it ...
1
vote
0answers
50 views

How to tidy up a massive spaghetti project [duplicate]

I previously asked this on StackOverflow, but was advised it was a better fit for Programmers. I have recently begun working on a codebase (as a Java developer) with the following characteristics: ...
1
vote
1answer
168 views

Design for object with optional and modifiable attributtes?

I've been using the Builder pattern to create objects with a large number of attributes, where most of them are optional. But up until now, I've defined them as final, as recommended by Joshua Block ...
0
votes
1answer
103 views

Reflective discovery of an inner class in an API

Let me ask you, as this bothers me for quite a while but appears to be subjectively the best solution for my problem, if reflective discovery of an inner class for API purposes is that bad idea? ...
0
votes
3answers
174 views

Drawback of using static method [duplicate]

For methods that never access instance variable or static variable and they act just like a function (name-spaced) and they are deterministic base on only the input arguments , I want to ask, are ...
0
votes
1answer
98 views

The Observer pattern using the pulling mechanism

I was wondering about the following implementation of public void update(Observable obs, Object arg) while i want to send to all of my observer and update using notifyObserver() i and passing a ...
35
votes
7answers
4k views

Why do people nowadays use factory classes so often? [closed]

I've seen the history of several С#/Java class library projects on GitHub and CodePlex, and it seems like a trend. Why do people nowadays use factory classes so often for almost everything? I.e. We ...
0
votes
1answer
117 views

How to generalize a classes that has identical function plus some additional function

I have some designing problems with my project. To illustrate my problem, I'll use the following two classes from my project. public class RAM_UserManagement{ private Map<int,User> userList; ...