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

2
votes
2answers
169 views

Make functions that imply other functions

I'm developing a game that often has repetitious code that I can't simplify. Example of what I do normally: Square object; GL11.glPushMatrix(); // Pushes a matrix stack down by one. This allows us ...
-4
votes
0answers
37 views

image upload fuctionality in a web application [closed]

I am working on a social networking site and I want to implement image upload functionality. So I was wondering, where should I store the images uploaded by any user Some folder in the server ...
4
votes
2answers
259 views

What is the correct approach for creating an application around a library?

I have a library that defines messages. In my particular instance, it's autogenerated code from an XSD using JAXB (Java). The messages can be very complex, with some members as objects and those ...
17
votes
8answers
41k views

Why does java.util.ArrayList allow to add null?

I wonder why java.util.ArrayList allows to add null. Is there any case where I would want to add null to an ArrayList? I am asking this question because in a project we had a bug where some code was ...
-3
votes
0answers
41 views

What cause the error opening trace file: No such file or directory (2) [closed]

I'm busy working on my Project of Call Recorder. When I run it in my mobile device, I get this under the logcat error opening trace file: No such file or directory (2) . Any one know what met be the ...
0
votes
1answer
45 views

Handling DomainExceptions using REST endpoint

Suppose I'm doing some DDD. Now, I have a microservice reflecting a bounded context/a part of a bounded context. Now, suppose there is a REST endpoint: '/somedomainmodel/someaction' My API user is ...
13
votes
6answers
1k views

Is creating the objects you think you will need ok in a first test in TDD

I'm fairly new to TDD and I have trouble when creating my first test when it comes before any of the implementation code. Without any framework to the implementation code I am free to write my first ...
0
votes
4answers
384 views

Why is it a bad practice to use underscores in names in Java? [closed]

I'm quite used to name methods as fooBar() and variables as foo_bar. For longer names, I find the underscores much more readable. In our university Java courses, we're discouraged from using ...
8
votes
3answers
10k views

Naming conventions for instance, local and parameter variables [closed]

I was discussing with a senior developper coding conventions to apply to our projects (mainly Java/JEE projects). I disagreed with one convention he proposed: Instance variable names should start ...
0
votes
1answer
154 views

Dealing with several custom getters

I have a data structure with data units containing different types of data. I've wrapped the data in "Field" objects so that each field is able to independently parse user input in a desired way. ...
0
votes
3answers
93 views

Best approach to implement an update operation of a container object?

I have an Invoice object wich may contain several FacturedServices objects stord as a list. In may interface, the user can edit an Invoice object, delete add or edit its FacturedServices list. Whe ...
2
votes
1answer
166 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
1answer
72 views

best way to export binary data with additional text attributes to a stream

I would like to create a command line API in a Java application to export a binary blob to stdout. I would additionally like to export certain attributes about the blob, ideally in a non-binary ...
0
votes
0answers
14 views

Extracting client specific code. refactoring possibilities required [duplicate]

I am facing a Design problem. I have a set of classes which writes data in XML,JSON or HTML formates for different clients. I have a class which receives Data and a XML, JSON or HTML writer as it ...
3
votes
3answers
195 views

How do you iterate through an array and delete an element?

I have an array and I can iterate through it. I know that it is impossible to change the size of an array; however, how do I take out a certain element that I not want in the array anymore? Example: ...
2
votes
6answers
3k views

Working with static constructor in Java

I didn't get a complete understanding of static constructors in Java. If it is allowed, why it is allowed? In what scenarios would you use it? What purpose would it serve? Can someone give me a simple ...
-2
votes
2answers
57 views

Should POJOs be abstracted?

My coworker tends to have each POJO implement an interface. Like Customer would implement ICustomer, with the motivation that we can now have multiple implementations of ICustomer. One example would ...
0
votes
1answer
59 views

Is it a good idea to include extra libraries in jars?

When creating executable jars for a java project, it is possible to create jar bundle which includes all the external libraries used. It is also possible to create a jar without those external ...
4
votes
4answers
2k views

Delphi to Java change - career advice [closed]

I'm a Delphi developer with aprox 5 years of experience. But now, Delphi seems to be dead, and the job opportunities are smaller. So, I want to begin learn Java, because I like it, and the job market ...
0
votes
1answer
77 views

Java Socket or SocketChannel

I am designing a server for a remote file store in Java and trying to decide whether to use asynchronous java.nio.SocketChannels or the older blocking model with Sockets. What kind of factors should I ...
1
vote
5answers
226 views

Understanding basics of object declaration in Java

Is there a case when an object is declared without a call to the constructor? as in, for example: ArrayList<Integer> grades; Or is it always the case that ArrayList<Integer> grades (as ...
35
votes
9answers
12k views

Why do schools teach arrays over List? [closed]

Most of the assignments in my school for the initial programming classes required me to use arrays. I work full time now, and I never used an array for any project that I have worked on. Even in the ...
0
votes
1answer
35 views

Restructure Service - Http - Notification communication

I am trying to restructure a project to make components reusable and clearer. Consider the following scenario: A WakefulBroadcastReceiver (in my case called SimpleWakefulReceiver) will start my ...
1
vote
0answers
43 views

How is ORB distinct from an endpoint?

What, fundamentally, am I misunderstanding about how to use appclient? The Application Client Container (ACC) includes a set of Java classes, libraries, and other files that are required for ...
12
votes
3answers
412 views

Is it a sane thing to return Streams wherever we would normally return Collections?

While developing my API that is not tied to any legacy code, I often find myself writing methods that are purely Streams pipeline terminated by collecting the results. Like this one: ...
0
votes
2answers
130 views

Working with two different database types for one application [duplicate]

Software: Java J2EE Application hosted on Tomcat Server. UPDATE The current software is JAVA Web application containing just JSP and Servlets no frameworks or anything. Simple JSP and ...
1
vote
1answer
151 views

Adding a graphical view to a system

I currently have an program in Java that simulates railway movements. Essentially, trains arrive on platforms, pick up and drop off passengers, and then proceed, respecting signalling where possible. ...
1
vote
2answers
74 views

Why am I getting field visibility warnings in Sonar?

Some static analysis tools flag non-private fields with Variable '[nameHere]' must be private and have accessor methods. Sonar consistently presents such warnings and wants to change all ...
-1
votes
3answers
106 views

Java and C++ connection? [closed]

Quick question about them. Are they semantic kind of way related? I am learning C++ and I want to start java too. Can I get confused when learning the two languages?
0
votes
2answers
100 views

How to write a new annotation that behaves precisely like an existing one?

Here is my use case. Suppose annotations did have inheritance and would automatically inherit the entire behaviour of the base class. Then I would do the following (note the two package statements): ...
2
votes
1answer
47 views

Use of validators for simple validations

I've been working in Liferay code, and I've come across this construct a few times: List<?> list; ... if (Validator.isNotNull(list)) { //do stuff }} The source code for Validator.java ...
1
vote
1answer
409 views

Programmatically extending Hibernate table/entity definitions in Spring, how?

I would like to know if there is a way —maybe with AOP— to extend table/entity definitions so that I can add functionality across the board that requires persistence. Let me explain what I want to do ...
3
votes
2answers
97 views

Enums in java switch-statements and completeness

I feel like I should be able to find an answer to this, but it turns out to be harder to search than expected... so: In C#, when we do something like: enum MyEnumClass { A, B }; static String ...
3
votes
3answers
318 views

have we come full circle with microservices, back to very old school approaches?

In terms of software architecture and design, how do microservices "stack up" (pun intended) against middleware? I'm coming from Java, and it seems like as you move away from straight REST as an API, ...
0
votes
1answer
288 views

2D Game Data Structure in OpenGL ES 2.0

I'm trying to come up with some data structures for rendering my map on OpenGL. It is going to be ~ 100x100 blocks(squares) total, with each block being around 100 pixels. However, the screen will ...
-2
votes
0answers
12 views

Database solution for multi-user uml-ish application [migrated]

I'm working on a Eclipse RCP-based application that will switch from single user local storage to multi-user database storage and are now considering what storage solution to use. It's sort of UML ...
-1
votes
3answers
119 views

Unfamiliar Array line of code in doPost() method

The code below is a code from the doPost method of a servlet, it is incomplete though. As you can see it is the logic for getting parameters from a web page, that is the first and last name and date ...
0
votes
2answers
372 views

Emulation of MMU accessing the contents of the registers

I'm having a play around with emulating a simple old CPU. I've set the structure up, so far anyway, as follows: The device is the main and creates an instance of the CPU. The CPU then creates ...
-4
votes
1answer
75 views

Hacking software development in Java [closed]

Is there a good tutorial about hacking in Java? Is it even possible? And if yes where do i start? I am programming a website with database in hibernate using Java, Struts 2, TomCat. And wondering how ...
99
votes
6answers
94k views

What does the Spring framework do? Should I use it? Why or why not?

So, I'm starting a brand-new project in Java, and am considering using Spring. Why am I considering Spring? Because lots of people tell me I should use Spring! Seriously, any time I've tried to get ...
4
votes
4answers
247 views

Why use an enum to determine node type in a parse tree?

The Sun Compiler Tree API uses an interface called Tree as the parent of all the different kinds of parse tree nodes (assignments, if-statements, class declarations, etc.). A part of this interface is ...
1
vote
3answers
151 views

Limiting complexity in JPA programs Java/Hibernate

I've been working on a new application for some months now. It's my first big JPA program, and is still in the early stages. However, the complexity of my JPA object tree is becoming a growing ...
1
vote
2answers
186 views

Is public final completely (not) ok in constant enum fields?

When I make enums that hold some fields, like my Settings enum, I like to make them public final to avoid lots of ( and ) keystrokes: public enum Settings { SETTING_TEST("bool_setting1", false), ...
3
votes
4answers
519 views

Interview question - Robot in a grid

This was recently asked to someone I know in an interview with a top engineering company. A robot has to move in a grid which is in the form of a matrix. It can go to A(i,j)--> A(i+j,j) ...
12
votes
9answers
11k views

Are Java certifications important for an architect role? [closed]

My this question is career path related. I want to know how much Java Certifications (SCJP, SCWCD and others) are important for an architect position. If a person posses a good experience in Java ...
-1
votes
0answers
20 views

How to find a string including non word character? [migrated]

How to find a string including non word character? Example input: l l'oreal s.a. l l' ab l search String: l output: XX l'oreal s.a. XX l' ab l Expected: XX l'oreal s.a. XX l' ab X I was trying to ...
2
votes
3answers
423 views

Can a Java Boolean be used for ternary (3-state) logic?

I'm trying to make a basic cache of a boolean value, and I did it like such: private Boolean _valueCache = null; private boolean getValue() { try { if (_valueCache == null) { // if cache ...
55
votes
11answers
10k views

A modern review of Java [closed]

I've been programming for a few years and I began in Java, and in my time I've found many different sources claiming Java to be an inferior language in some way or another. I'm well aware that each ...
0
votes
5answers
286 views

Interview Question - Adding Method to interface that has been implemented by thousands of class [closed]

There is scenario where I have Interface X, which has been implemented with my thousands of classes. Now I want to add new method in that Interface X. So how to make the changes in minimal way to ...
0
votes
1answer
135 views

Program to look at the first say 5 characters of a word and return a string if that string is actually the first 5 characters of a word?

For example, say I have a string and it has the letters: RDNAL This is not an actual English word or it doesn't start an actual english word, so the program would skip this string and would avoid ...