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

Which patterns to apply for “User Manager”

I developing a social application and I neeed to create a User Manager that is responsible for managing certain types of user. A user who enters in to the system will be a new user or an existing ...
0
votes
0answers
21 views

Getters with data conversion in Java VOs

I am working on a standard Spring application where DAO layer returns entities to service layer and service layer returns VOs to other services and controllers. In a certain scenario, we have a VO ...
-1
votes
0answers
19 views

Weird Override and implementation [migrated]

I am currently programming an android app, but I have a problem. I want to use GreenDroid for my project but while compiling the compliler give me an error : The return type is incompatible with ...
2
votes
1answer
43 views

Domain object model: query by id vs object

Let assume I have two simple model classes: Product and Brand It is obvious I have a query method in Product class like this Product product = Product.findById(123); What if, I want to query ...
-3
votes
0answers
21 views

How to launch browser from Java WS and log on page by SSO?

I have an Java Web Start application which communicate with J2EE server application (JBoss). User is logging in (login & password) and after that doing some operations. Now I would like to add a ...
0
votes
0answers
22 views

Handling server failure using serialization

In my program, there is a central server, and I want to store its state. I'm using serialization for this, I am serializing the data after every 2,3 seconds. So that whenever server fails, it can come ...
-1
votes
0answers
23 views

Spring-Quartz scheduler throw NoSuchMethodException [on hold]

I'm using Spring MVC to develop my project and I want to use quartz-schedule to set time for an method in controller. But there is java.lang.NoSuchMethodException occurred. This is my declared code: ...
1
vote
1answer
103 views

Differences in design/thought process for OO in Java and JavaScript [duplicate]

Despite sharing a similar name and syntax, Java and JavaScript are quite different. However, they both have Object Oriented features. As a JavaScript novice, the main differences that I can see ...
2
votes
3answers
120 views

How do I show 'creates' in a UML class diagram?

Let's say my code is going to look like this: public class MyController { private Foo foo; private FooGenerator fooGen; //setters public void work() { this.foo = ...
1
vote
3answers
117 views

Using prefix/postfix increment operator for simple incremental array access rather than actual index numbers

I cannot decide which method is better with consideration of both readability and fault-tolerance. Method #1: Object[] objects = getArrayOfKnownLength(); int i = -1; someMethod(objects[++i], ...
-2
votes
1answer
74 views

Java - Concept question: LinkedHashMaps vs POJOs?

EDIT: I'm just going to ask a single question instead of presenting a problem and asking for advice on a specific design decision in the solution. Given a batch of data from a database, collected ...
2
votes
2answers
152 views

return a object without returning the reference

i'm having some trouble with returning objects and lists of objects. To problem is I want to return a object in my example an developer but I don't want to give the reference. What's the best ...
0
votes
1answer
52 views

how can the presenter or view interact with the model in the MVP pattern?

I'm learning the MV* patterns. MVP in this case. I'm trying to refactor an old android application into the MVP pattern to make things less tightly coupled, but I'm struggling one one concept. I know ...
4
votes
5answers
427 views

Is it okay to go against all-caps naming for enums to make their String representation simpler?

Several times I've seen people use title-case or even all lower-case naming for enum constants, for example: enum Color { red, yellow, green; } This makes working with their string form ...
0
votes
1answer
48 views

Using Websocket for a multiple-page website

Is using Websocket (in particular, in a Java, SpringMVC webapp, with the Spring Websocket support libs, but the question probably applies to any language) for a multiple-page website a bad idea ? ...
-6
votes
0answers
60 views

getting square root(without using Math.sqrt function) using iteration loop or recursion [on hold]

This is a problem mentioned in one of exercises in Think Java book. The problem is to get a square root of a number that has been input. ...
5
votes
2answers
179 views

Does sun.misc.Unsafe give access to the system or just the JVM?

Please note: Although this question involves microcontrollers, it is at its core, a Java question, and so I believe it can be answered by any battle-weary Java guru. I stumbled accross this blog ...
-1
votes
0answers
34 views

Tcp server language choice [on hold]

Is there any reason to use a specific programming language for TCP server programming? Or java, c# can achieve same as c++ without any noticeable performance loss?
1
vote
0answers
35 views

Will using a pure MQTT approach be the right decision?

I plan to provide additional functions for a closed-source 3rd party point of sales application. That application is used in restaurants, is run on Windows and uses dbase style databases. I know the ...
50
votes
7answers
8k views

How do you avoid getters and setters?

I'm having something of a hard time with designing classes in an oo way. I've read that objects expose their behavior, not their data; therefore, rather than using getter/setters to modify data, the ...
3
votes
3answers
152 views

Design suggestions for converters in Java

I'm trying a set of converters which will convert an object to some older form. And there are different objects which are converted. By older form I mean changing the values of some fields and in case ...
6
votes
3answers
162 views

Advantage/Disadvantage of having all variables declared in a JUnit Test

I've been writing some unit tests for some new code at work, and sent it off for a code review. One of my co-workers made a comment about why I was putting variables that are used in a number of those ...
0
votes
0answers
48 views

How to ace online/whiteboard coding interview [closed]

I am a fairly experienced Java developer(12 years), and if I have to believe my reviews, I exceed expectations almost every year. After 5 years in my current workplace, I recently started looking ...
14
votes
2answers
1k views

Declaring a class final? [duplicate]

I like my code to be written well; however, I have run into not really an problem, but more of a question about conventions. Say I have this class. public class Test { public void doStuff() { ...
0
votes
0answers
27 views

Run fat jar as a service on Amazon Linux EC2 instance using Ansible

I want to deploy a Ninja app to an EC2 Amazon Linux instance using Ansible. Being a Linux noob and completely new to Ansible, I wonder what the best way would be to start the app via Ansible as a ...
0
votes
1answer
36 views

Java: Weighted Selection help [on hold]

I have this code that randomly selects a item from a enum. Each of the enum items have a integer weight to it. The higher that weight is, the higher chance that item has of being picked. Here's what ...
0
votes
1answer
131 views

I need a data structure for a card game

I am programming a card game in java, and unsure what data structure I should use for the player's hand. I considered using an array, with one integer to traverse the array and another integer to ...
2
votes
1answer
88 views

What is the motivation behind the @ImplementedBy annotation in Guice?

I recently read about the @ImplementedBy annotation available in Google Guice. It allows the programmer to specify a binding between an interface and its implementation for future use in dependency ...
-2
votes
0answers
30 views

Toogle Button is not Working properly on wrong password [closed]

I'm trying to Enable/Disable Bluetooth on Toggle Button and Also, there is a additional functionality and that is asking password on enable/disable. Toggle Button is taking Default state of Bluetooth ...
0
votes
3answers
231 views

What arguments are there to use a coding style for each distinct language? [duplicate]

I recently had a discussion about our coding style for C# projects. Two things in particular were very hard to agree upon. Method Naming C# has the de-facto standard of naming (at least public, ...
-1
votes
0answers
6 views

eclipse acting weird when creating methods [migrated]

I don't see what could be wrong here, I was working on a different method but had some problems so I tried to simplify it to check where could the mistake be but I ended going up into this very simple ...
2
votes
1answer
120 views

Does the LGPL apply if I rewrite a portion of JasperReports in C++?

I would like to rewrite a portion of the JasperReports library in C++. The library will read from the same XML format used by JasperReports. If I integrate this C++ library to my proprietary ...
0
votes
1answer
87 views

Should a comparison method ever return the same type back as it's comparing?

First, this is homework, but no, I'm not asking for anyone to do any code for me. My course start date isn't for another month (it's online), so I can't ask for clarification. I thought I'd see if ...
-4
votes
0answers
44 views

what is necessary to develop complete system for my senior project [closed]

I am taking my senior project after three month it will be building system with professional GUI, free of error and maybe will be connected to internet with databases and reports with simple word ...
-5
votes
3answers
101 views

Is it possible to Style a csv file? [closed]

I am generating a csv file in java and want to use MS Excel to read it. Unfortunately it looks very simple, with no formatting. Is it possible to add styling to a csv file (using java) so that when ...
-1
votes
0answers
68 views

Binary search tree - implementation of insertion [closed]

I have a problem. I tried asking for it in Stack Overflow, but I had no luck there. Can somebody please help me, the implementation of the method for insertion in a binary search tree, for what I have ...
-1
votes
0answers
18 views

Write xtend code with IntelliJ Idea [closed]

I've been developing software with xtend using Eclipse. Now I found IntelliJ Idea which I find much faster than Eclipse. Is it posible to work with xtend + intellij?
0
votes
1answer
118 views

Changing the Garbage Collector on your JVM [closed]

My understanding is that the JVM specification only defines the behavior of a garbage collector, but does not provide implementation details. This means it is up to the JVM implementation to build the ...
2
votes
0answers
67 views

Cross-compiling Java app to run directly on ARM

Please note: although I am using ARM SAM3X8E in this example, I'm just using that as a concrete example, and the answer to this question could easily be given using any other MCU such as AVR, etc. I ...
1
vote
0answers
29 views

Embedded tomcat cold deployment without service disruption

I have the following scenario. For various reasons I chose to use embedded tomcat for my rest backend that will form a cluster of AWS machines. I will want to deploy fairly frequently updates ...
0
votes
2answers
121 views

What is the best type to represent a number in java and why? [closed]

I am developing a dynamically typed, interpreted programming language, which is interpreted by a runtime written in Java. As Java is statically typed, I need to define how the numbers used in the ...
3
votes
1answer
52 views

Do I need a web-service for this case? Data-synchronization over multiple clients

I'm new in this area and a little bit confused about my current thoughts on a web-service implementation for my application. I want to synchronize all connected clients with the current data on a ...
1
vote
1answer
42 views

role based access control model in object oriented

I want to prepare a swing application. I am designing a role based access control model in mvc design. When a view wants to request something from a controller, how can this request be realized in ...
1
vote
1answer
63 views

Java partial enum backed by the database

I have following problem: need to use enum in my java code, since I'll have to ask in my business logic things like if(someting == enumname.VALUE_ENUM){... but I don't have all the enum types at the ...
5
votes
5answers
242 views

Does it always make sense to “program to an interface” in Java?

I've seen the discussion at this question regarding how a class that implements from an interface would be instantiated. In my case, I'm writing a very small program in Java that uses an instance of ...
3
votes
1answer
116 views

What was the date of the Java Alpha and Beta releases

The date of the public 1.0 release of Java is easy to find: January 23, 1996. But there were public Alpha and Beta releases before that, and in December 1995 Java already appeared on the list of Time ...
4
votes
1answer
174 views

Is Collection.stream().filter().forEach() inefficient compared to a standard for each loop?

IntelliJ IDEA recommended to me just now to replace the following for-each loop with a Java 8 "forEach" call: for (Object o : objects) { if (o instanceof SomeObject) { ...
0
votes
0answers
23 views

Classes, Datatypes and replicating Methods [duplicate]

I've gone from writing code procedural-style to object-oriented recently and during my development as an object-orientated programmer I have made a few mistakes. What I have been doing is, inside my ...
10
votes
2answers
430 views

Java: why is there a Comparator interface but no Hasher and Equator?

This issue is most apparent when you have different implementations of an interface, and for the purposes of a particular collection you only care about the interface-level view of the objects. For ...
26
votes
4answers
3k views

Why is .compareTo() in an interface while .equals() is in a class in Java?

I want to know why the .compareTo() is in the Comparable interface while a method like .equals is in the Object class. To me, it seems arbitrary why a method like .compareTo() is not in the Object ...