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
1answer
19 views

How to handle xml element with both CDATA and regular data using SimpleXML

I'm struggling to understanding how I can deserialize the following response from an RSS feed. I need the text blah blah blah etc as well as the embedded image source http://host/path/to/picture.jpg. ...
1
vote
1answer
50 views

Is accessing lower tier members of an aggregate to perform an operation bad practice?

I am currently building a small project that is supposed to keep track of recipes. Each recipe has a bunch of information, including a rating for said recipe. Since the rating has some additional ...
-2
votes
0answers
17 views

How can i change the element of XML using XSLT [on hold]

I am new in XSLT. My Requirement is: I have one XML something.xml It Contains <Parent> <child1> <firstname>abcd</firstname> <lname>dcba</lname> </...
1
vote
1answer
39 views

Parse both en_US and en-US as locale in Java

I am writing an API (using Java) that takes locale as a parameter. We want the clients to be able to specify "en-US" or "en_US" as they both seem to be widely used across all languages. I did go ...
0
votes
1answer
41 views

How to deal with different configurations with non-overlapping properties?

I am working on a project based on the Java EE technology. First I'd like to tell you what I want to achieve, then what I already tried. Task: Imagine two types of configurations, which you want to ...
1
vote
2answers
128 views

Opportunity cost of DIY DI?

Java here. I have always used Spring DI (for Spring projects) or Guice (for non-Spring projects) for dependency injection, and have always loved them. I recently took a job where they do 100% "DIY DI"...
1
vote
0answers
1k views

Spring bean injection into a hibernate validator constraint

I have a controller method like listed below whose argument is annotated with @Valid to validate PasswordChange object using a Hibernate validator @Constraint. Both PasswordChange and a sample ...
2
votes
2answers
98 views

Would it be possible to create a class during runtime execution?

This might be a little unrealistic bu i will ask anyway. Would this be possible to create literally create a new class during the run time execution, i don't mean a new instance, i mean a new class ...
0
votes
1answer
103 views

What algorithm or program does Java use for arithmetic?

I was looking at bitwise ways to multiply and add numbers without using * or + operators. But I want to know that it might be possible that java may already be using a better approach underneath. I ...
1
vote
1answer
395 views

JEE MVC, controller calls the interface instead of the interface implementation

I'm following this tutorial: http://wiki4.caucho.com/Building_a_simple_listing_in_JSP It creates a basic web application in Eclipse using the MVC pattern with Resin as the web container. Here's the ...
4
votes
3answers
1k views

Software licensing and Copyright of Open source

I have seen some source code containing Copyright notice in the beginning of the file. Most of them are either GNU General Public License or Apache License. If I want to develop any open source ...
2
votes
2answers
147 views

Is 20 Java classes for just making a REST call too much?

In an Android project, I am using dagger 2 for dependency injection, applying mvp design pattern, and I am writing interface for almost every class. Although it does achieved the separation of ...
0
votes
1answer
26 views

Java searching for multiple keywords through a list of URLs

Hey guys I was wondering if anyone could point me into the right direction as to how to start this. And its been awhile since I've programmed in java. I basically have to search through a list of ...
1
vote
1answer
59 views

Java PrintWriter vs JSP

I just want to ask an opinion, which are the best practice to use html between this two option: 1) Use JSP by creating html page there 2) Generate html using Java server side by using PrintWriter ...
0
votes
0answers
46 views

How to handle ID's with resources that can be combined?

Early on in my app, there were simple Customer objects with an int id. In my database, some customers are split into multiple accounts for organization purposes. For ex. "CustomerA" (Main account) (ID:...
0
votes
2answers
98 views

Best Communication strategy for monitoring dashboard

I have a requirement where I need to display certain stats on Admin Dashboard in my web application (Angular+Java). These stats (transnational data) are being generated on different servers (connected ...
0
votes
1answer
81 views

How do I integrate hibernate and REST web service in java?

I am going to develop which will be web application as well as mobile (android / iOS / windows) application. The database in this application will be managed by Hibernate. Also as it is cross platform ...
7
votes
1answer
226 views

Why are checked vs. unchecked exceptions called “the controversy” in Oracle Java tutorial?

I am new to Java and was reading its documentation on exceptions., and especially the Unchecked Exceptions — The Controversy page. The bottom-line says: If a client can reasonably be expected to ...
-2
votes
0answers
27 views

Need help in optimizing my arraylist class which contains combination of pair [on hold]

Need help in optimizing my arraylist class which contains combination of pair: import java.util.ArrayList; import java.util.List; public class FieldsProvider2 { private MyObject object; private ...
2
votes
3answers
533 views

Could the creation of many methods in Java affect performance? [closed]

I was told by a colleague that in Java, the performance may be worse if we create more methods, stacking many methods calling over them in JVM, specially in a Java EE environment. This seems to ...
13
votes
3answers
1k views

The suffix Exception on exceptions in java

Specifying a suffix of Exception on exception classes feels like a code smell to me (Redundant information - the rest of the name implies an error state and it inherits from Exception). However, it ...
21
votes
3answers
3k views

Why should I use “functional operations” instead of a for loop?

for (Canvas canvas : list) { } NetBeans suggests me to use "functional operations": list.stream().forEach((canvas) -> { }); But why is this preferred? If anything, it is harder to read and ...
2
votes
2answers
614 views

How to efficiently handle related data in MVC?

Talking about MVC with servlets and JSP's, in a context about products and manufacturers , when querying the application for a list of products: the servlet loads a list of products from the ...
0
votes
0answers
22 views

Templating changes in Spring boot 1.3

I am currently studying java using Maven, Spring boot, and SVN. I have been assigned the task of getting both the revision number and timestamp of the project to store in a text file and eventually ...
0
votes
1answer
95 views

Divide java web app into smaller web app

I've a web application that consists of 3 main technologies: JSF, jax-rs and websocket. All three are coupled together with the help of CDI injection and JPA. That means that when a user login, he ...
9
votes
4answers
692 views

Programming style in Perl

I work in Java so basically I use OOP paradigm during coding. I am about to start working in Perl and I was wondering what is the paradigm that Perl developers follow. In wiki it mentions that it ...
2
votes
3answers
187 views

Preemptive interfaces in Java - good, bad or “a matter of taste”

I frequently come across projects that strictly define an interface for each and every class. 90% of those interfaces feature only a single implementation. Proponents of these "preemptive interfacs" ...
-1
votes
2answers
139 views

Is there a way to refactor the given code snippet without using if statement? [on hold]

I am very new to java programming and I recently learned that using too many if else condition statements is not a good programming practice, and I am wondering is there a way to refactor the below ...
1
vote
2answers
89 views

Create jar of a java application where entry point is an external program

I have a java plugin written for a software called icy. Since the entry point of program is when the plugin is activated from the software, I am having trouble about how to mention that in manifest.mf ...
0
votes
3answers
147 views

Cyclic dependency in this project design

I have 2 modules (containing multiple classes). Let's call them Module A and Module B. Module B has a dependency on Module A: Module B -> Module A. Now, I have created an utility class C, which A ...
-3
votes
0answers
32 views

How can i get two input simultaneously using scanner? [closed]

In my program i'm getting two input but it return one value another as null. i couldn't find out. please anyone clarify my error. Input: k 1 output: king of null public class Cards { ...
2
votes
5answers
421 views

Why isn't byte | bit the only built in data type?

All languages I have seen so far have multiple builtin data types (int, double, float, char, long...). But if we look closely, they are just arbitrary arrays of bits, the only difference between them ...
1
vote
2answers
155 views

Structure of RESTful Service with Java Spring for Beginner

I am relatively new in terms of Java web development skills. I have a project that I think would make a good candidate for a RESTful service from what little I understand about APIs. I'm trying to get ...
2
votes
1answer
155 views

Should I return Iterable or Enumeration in Java

In order to achieve better immutability, should my API return java.lang.Iterable<T> or java.util.Enumeration<E>? Since Iterable has a remove() method, one could say Enumeration is the ...
0
votes
2answers
248 views

DDD Request Validation Handling

I stuck somewhere that I can't find a solution! There are plenty of validation questions here, but as far as I see, most of them were asking about entity validation. But what about request validation? ...
4
votes
3answers
288 views

Generating Java Classes with Compile-time Value Parameters

Consider a situation where a class implements the same basic behavior, methods, et cetera, but multiple different versions of that class could exist for different uses. In my particular case, I have a ...
1
vote
1answer
40 views

Redesigning schedule value hierarchy

I have a couple of schedule value classes that represent the value a schedule holds for a specific slot. First, there's the ScheduleValue class for schedules with two dimensions, where the first one (...
-5
votes
0answers
55 views

Is programming for Android 3 similar to programming for Android 6? [on hold]

I am interested in creating apps for android, and my school library just happened to have a book for Android 3. I will be finding tutorials online, and seeking newer resources online (obviously) but ...
82
votes
9answers
8k views

Has / can anyone challenge Uncle Bob on his love of removing “useless braces”?

I hate referencing paywalled content, but this video shows exactly what I'm talking about. Precisely 12 minutes in Robert Martin looks at this: And says "One of my favorite things to do is getting ...
0
votes
0answers
54 views

Using java interfaces to narrow the classes public interface

There is a lot of content on the web discussing if it is worth defining an interface if only one class implements it. The answers are mostly either "Yes, because you probably need to mock it anyways" ...
-1
votes
1answer
24 views

Not able to remove an element from map(NamedValue) while iterating on same map? [closed]

Is there any way that I can remove or add element in map I am currently iterating(using iterator) upon. Please suggest.
0
votes
1answer
95 views

How to avoid nested Threads?

I often have a situation where I first need to do something in the UI thread (Android in this case), then to some networkstuff in an extra thread, switch back to the UI thread and udate the layout, ...
0
votes
2answers
107 views

How to make two threads interact with each other without stopping the execution of the thread?

This might sound similar to some of the other questions but it does not deal with wait or notify. I have two threads which do two different things The first forms a process in the background and ...
-4
votes
0answers
58 views

What is the purpose of `1 + Math.abs(rn.nextInt() % 6)`? [closed]

int a; Random rn = new Random(); a = 1 + Math.abs(rn.nextInt() % 6); System.out.println("The result: " + a); What does this line do a = 1 + Math.abs(rn.nextInt() % 6);?
0
votes
0answers
46 views

How to shift elements within a matrix?

I have a grid of objects that occupy cells in a grid. Basically similar to android launcher - with icons and widgets and whatnot, because that's what I am building. To keep track of which cells are ...
0
votes
1answer
80 views

strategy to display value for a html select

Strategy to display value for a html select I have a spring boot, application. On the client side, I use JQuery I would like to know the strategy to display "static value" for a html select. ...
4
votes
3answers
678 views

Recommended value to pass instead of String parameter for a method in java

We have a method called attachDevice(Device device) which has only one argument. We had a situation to overload this method with one more parameter as like attachDevice(Device device, String ...
0
votes
2answers
109 views

Using spring to Avoid Singleton pattern

Considering that Spring framework can manage pretty everything related to object creation (life cycle, object scope ..), is it longer necessary to use singleton pattern in an application using the ...
0
votes
0answers
12 views

Efficient way to find the source code of a given gialog in Java [migrated]

I am working on a Java app with some 100K lines code base. Searching for the source code of a given dialog is tedious. Searching by text is impractical because dialog title and button names are very ...
14
votes
2answers
7k views

Why should a builder be an inner class instead of in its own class file?

Many Builder Pattern examples make the Builder an inner class of the object it builds. This makes some sense since it indicates what the Builder builds. However, in a statically typed language we ...