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
vote
1answer
49 views

Why for-each has colon insted of “in”?

From Java 5 language guide: When you see the colon (:) read it as "in". Why not use in in the first place then? This has been bugging me for years. Because it's inconsistent with the rest of ...
-5
votes
0answers
31 views

company upgrade java versions [on hold]

The company I worked for is considering upgrading the old java version of 1.6 to 1.8 and I been thinking what should we do for the releases prior to the change date? for example starting from ...
1
vote
2answers
39 views

Refactoring my code that depends on a renamed library method

Say third party library Beautify renames one of their methods from beauty to makeBeautiful because they want the method to be a verb and by some lack of initial planning didn't do this from the start. ...
0
votes
0answers
23 views

Incorporating external web services in Java/Spring web app

With traditional Java/Spring web apps, I've historically used an JEE architecture where there's a domain tier and a web tier. The web tier mostly contains web controllers. The domain tier includes ...
1
vote
0answers
32 views

How to report multiple errors as a result of validation?

I have a class that transforms a complex model, for example an abstract syntax tree or intermediate model. The model can be either valid, invalid or partially invalid, i.e. it contains errors but some ...
-4
votes
0answers
25 views

Replace hard-coded strings in lookup to dynamic lookup [on hold]

Map<Integer, String> lookup = new HashMap<Integer, String>(); lookup.put(0, " Created"); lookup.put(1, " Started"); lookup.put(2, " Completed"); lookup.put(3, " Closed"); private String ...
-3
votes
0answers
29 views

A portable configuration parser for both Java and Python [on hold]

I figured I should get everybody's opinion before potentially reinventing the wheel on this one. I need a configuration parser that has the following qualities: 1) It's hierarchical, similar to json ...
0
votes
0answers
5 views

Setting two objects equal to each other and finding the Boolean result of it [migrated]

Calendar calendar = new GregorianCalendar(2015, 2, 1); Calendar calendar1 = calendar; Calendar calendar2 = (Calendar)calendar.clone(); System.out.println("calendar == calendar1 is " + (calendar == ...
-1
votes
3answers
190 views

Java constructors confusion?

public class example { private String one; private String two; public example(String one, String two) { this.one = one; this.two = two; } public static void ...
-5
votes
1answer
38 views

Proper use of break; [on hold]

I am trying to establish my POINT value when the sum is equal to 4, 5, 6, 8, 9, 10, but terminal continues to execute my code even after the break;. Can someone please explain why this is happening? ...
-3
votes
0answers
96 views

Re-Design without if statements/ minimal if statements? [on hold]

I've been stewing on this for a while. To start, I have a class that acts as a builder for XML. public class MyBuilder(){ private MyModel model; private XMLService xml = new XMLService(); ...
12
votes
4answers
5k views

If my IDE is so smart, why do I need to cast “clone()”?

My IDE (NetBeans) type checks my Collections while I am typing code. But then, why do I have to cast the returned object of Object.clone()? Which is fine. No harm no foul. But still, I don't ...
-4
votes
0answers
52 views

Key areas when advancing from junior to regular java dev [on hold]

First i hope this is the right section of SO for posting this questions I'm finishing my first year as java developer with hope of advancing to regular(senior) dev so this question came to my mind. ...
-5
votes
0answers
38 views

what 's wrong with the xml? [on hold]

as you see follow(it's circled by red line): as follow is the ui xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:layout_width="197dp" ...
0
votes
3answers
59 views

Spring-MVC : Testing code by automatically running it in UI

I am working on a Spring-MVC application(config XML based, no Main class) in which I would like to do testing. I have known that there is a way to test code which is backend+frontend code. For that, I ...
4
votes
2answers
49 views

Referencing extendable ordinal numbers

I have a class that is basically a container (or composite) of 4 other objects. I'm trying to figure out the "best" way of referring to these objects, while still allowing it to be robust enough, so ...
1
vote
1answer
81 views

Transitioning from C++ multithreading to Java multithreading

In C++, I've been accustomed to using threads in the following way: #include <iostream> #include <thread> #include <mutex> std::mutex m; int i = 0; void ...
7
votes
1answer
90 views

Is the complexity needed to prevent downcasting from constructor to overridden method worth it?

Invoking non-final instance methods in constructors risks downcasting from a constructor to an overridden method as such: public class Start { public static void main(String[] args) { try ...
-3
votes
0answers
25 views

For my MenuBar in my Swing app does it follow OOP standards to just use static methods and fields or a singleton?

I'm working on my first full scale application (Java/Swing). When adding functionality to my menu buttons, I'm finding it difficult to manage my Menu. Like stated in the title, is it good practice ...
-5
votes
0answers
39 views

Direction of software development [on hold]

I am facing two camps. They can be essentially be broken down into these categories: open source, modern language development vs enterprise development in java. My question is, which is the industry ...
-5
votes
0answers
28 views

Please Help Me With My Java Swing Gui Code [on hold]

Please help me i want to now if there is a component to perilously set size and position. I would also now if that component is .setBounds(); here is my code. public static void main(String[] ...
6
votes
2answers
107 views

Returning Unmodifiable Collections only tees you up for runtime exceptions?

Seeing as how there are no distinct Unmodifiable Collections interfaces, aren't you just setting yourself up for runtime exceptions by returning Unmodifiable Collections from method invocations? ...
-1
votes
0answers
59 views

What languages would compliment COBOL? [on hold]

That title alone should direct enough curiosity to this question to get me some answers..... I just started working for a state government office that depends on COBOL for processing payments and ...
-1
votes
0answers
30 views

multi-consumer multi-queue rabbitMq Spring (read message by message for each consumer process)

The goal of this project is a bit technical but hopefully to have someone to advise me better. Note that I work in a multi-clustering context, which means that I have the same program running on ...
3
votes
1answer
61 views

In MVP pattern should the View instantiate a Model object based on UI contents, or just pass these contents as parameters to the Presenter?

I'm using MVP pattern in an android app that I'm developing. I have basically 4 elements: The AddUserView where a new user can be added: The AddUserPresenter The UserInfo (the pojo) The ...
2
votes
1answer
70 views

where to put methods that manipulate objects

I have a controller method as follow: public class RoomsController { @RequestMapping(method = RequestMethod.GET, path="/v1/rooms/{name}") public ResponseEntity<?> ...
7
votes
2answers
91 views

using Integer objects in Java API

I was reviewing a coworker's code, and noticed that he was using Integer objects instead of ints in some APIs (getters, setters, instance variables, and method parameters). When I asked him why, he ...
8
votes
4answers
1k views

Why would passing objects through static methods be advantageous?

Why would there be an advantage to use a static method and pass the reference to an object as a parameter rather than calling the method on an object? To clarify what I mean, consider the following ...
-1
votes
2answers
93 views

Chat Protocol Implementation

For a school assignment we need to implement a homebrewed protocol. We make usage of plaintext commands to send and receive messages. The commands underneath are currently supported by the messaging ...
2
votes
1answer
198 views

LinkedList - why no direct .next() on elements?

I never understood this: why is it that I can't seem to find a core collections api somewhere that Allows me to retrieve elements that have a direct .next() or .previous() method on them without all ...
-2
votes
0answers
18 views

How to approach large enterprise code [duplicate]

I've noticed that I get very detailed when going through some code I haven't seen before. This only makes me more confused, diving into all the methods, thinking about all the cases at once that could ...
-3
votes
1answer
69 views

How to save strings and integers permanently to a users device?

I'm building an app that requires the user to purchase content and sign to a User Agreement Contract. However, I'm not too sure where to start with in-app purchases and saving data types to the users ...
0
votes
1answer
52 views

Synchronisation with offline system

I'm designing a system from which I will synchronise business data from mobile device that have an embedded application that generates datas and send them back to the server. Each line synchronised ...
4
votes
3answers
223 views

Queue vs Threads

I'm implementing a data processing software. The software gets form the network thousands of events that must be processed in according to rules. I implemented a multi-thread service, which receives ...
0
votes
1answer
256 views

How could this be considered performant code?

I came across this (Java) code yesterday and can't figure out why someone would have done this in any language. In what scenario, language, paranoid delusion would "removing" values from an ...
1
vote
0answers
43 views

How do I design concurrent scalable system with guaranteed ordering? How about Akka?

I have designed a simple PoC system that processes a feed of prices that tick. It consumes a stream of "Ticker, Price" objects off JMS and updates a map, so that the map simply contains the latest ...
1
vote
1answer
68 views

Manual reload of Java classes static block

I have a static block which fetches data from database. This data is then being used by instance method. Since static block will be loaded once I fear that the data won't change in its lifetime. How ...
0
votes
0answers
50 views

Using counter or constant for parameter position

Suppose that I have the following Java code: int i = 0; PreparedStatement statement = con.prepareStatement("SELECT * FROM table " + "WHERE field1 = ?, field2 = ?, field3 = ?..."); ...
0
votes
1answer
69 views

Is it good practice to acess database in mapping between object

Situation I receive message from a 3rd party, and these messages are use to create or update database information. Message and data to be updated can be de-serialize in object form, but are not ...
5
votes
2answers
161 views

How do I use checked exceptions without violating the Law of Demeter?

Given a language that enforces checked exceptions (let us assume Java), how do we design an API that can throw exceptions without violating the Law of Demeter? To put this question in the proper ...
5
votes
1answer
398 views

Are we abusing static methods?

A couple of months ago I started working in a new project, and when going through the code it stroke me the amount of static methods used. Not only utility methods as ...
-5
votes
0answers
21 views

how to implement TextWatcher when my Json is ready? [closed]

I am facing problem with my project, I want to connect my app to local host, I have seen the ways to do that and picked up the simplest one using json, thus I stopped on the way of implementing my ...
0
votes
3answers
79 views

How to represent an object with actions that can only be used in a specific situation?

Let's say I'm designing an RPG type game, and this game has a turn-based combat system. There are some things that the player character/non-player characters can do inside and outside of combat. For ...
-1
votes
1answer
49 views

How to display a non-interactive message on a JFrame? [closed]

I'm writing this code here: import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JTextArea; import javax.swing.UIManager; public class FirstJavaClass { public static void ...
0
votes
0answers
35 views

Customizing xmlAdaptor in JAXB

I have hashtable which contains columnName and column value. My hashtable contains key,value pair as like columnName = columnValue columnName = columnValue columnName = columnValue columnName = ...
0
votes
0answers
51 views

Calling a method on a constructor method [migrated]

I saw this line of code while doing an Android tutorial, and it compiles: Date date = new GregorianCalendar(year, month, day).getTime(); How can you call the getTime() method on a constructor. To ...
3
votes
1answer
168 views

What are modern develop-deploy-test techniques for non-interpreted languages?

I have strong web-developer background, where in order to show client a demo I've uploaded a solution to demo environment and sent over a link. If case client asked to make changes, I did them in ...
1
vote
1answer
146 views

Is it true that JVM language is difficult to integrate with C than other language? [closed]

I have seen many libraries provide high level API in the language like python or lua. For example: The linear algebra library "Trilinos" provides a python API. The deep learning framework "torch" ...
-3
votes
1answer
70 views

Which is best practice to save uploaded images in a database or in a folder [duplicate]

I am developing a project in jsp and servlet and I am using mysql database, I want to upload many images from my application but I am confused where I save uploaded images in the database or in a ...
3
votes
2answers
99 views

Is an attempt to create a duplicate resource, e.g. a user, worthy of throwing an Exception?

Say I have an REST API for creating users in an application. The request goes to a controller, which marshals the request data into a domain object, and passes it to a service to create a user. Now, ...