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
3answers
161 views

Documenting intent Vs knowledge

It is said you should document the intent of your function or class which I agree with. However recently this line became a little bit blurred when I was wanting someone to document why this ...
0
votes
5answers
197 views

classes/inheritance, how do I handle special cases that require more change

I often find myself in this situation where I have a base class that does a lot of graphics. There are, for example, three strings that are positioned top, middle, bottom of an element. Like a scale ...
3
votes
3answers
127 views

How many threads should I use in my NIO server?

I've built a Java NIO TCP server, it currently uses four threads. One ServerRunnable thread that uses a selector and three worker threads. I've been looking around for some information about this, ...
0
votes
2answers
279 views

Is it ok to break the “is a” relationship if I just want part of a class' functionality?

I asked a question about extending TreeMaps into "sort by value" TreeMaps on the "code review" site on stackoverflow. Based on the response, I re-wrote the code. I like it. But, it feels like I might ...
2
votes
2answers
180 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 ...
7
votes
2answers
239 views

Java System class implementation

The Java System class contains various data members and methods that make perfect sense being there. For instance: System.in (variable) System.err (variable) System.out (variable) System.exit(int) ...
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
405 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 ...
0
votes
2answers
163 views

Storm topology to handle “dating website”-like workloads

suppose im writing a dating website, similar to okcupid. there are profiles, and i need to compute the (N^2) "match" table - given every 2 profiles whats the match between them? I was thinking this ...
3
votes
3answers
221 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: ...
1
vote
2answers
147 views

Observer pattern without state change?

My question is whether there is a similar pattern to Observer that does not imply a state change in the observed object. The following is a concrete example: I have a ConnectionFactory class which is ...
4
votes
2answers
269 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 ...
-2
votes
2answers
60 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
68 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 ...
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 ...
1
vote
0answers
51 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 ...
0
votes
1answer
38 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
5answers
235 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 ...
12
votes
3answers
444 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: ...
1
vote
2answers
90 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
117 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
148 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 ...
2
votes
1answer
52 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 ...
3
votes
2answers
120 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
351 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, ...
-4
votes
1answer
80 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 ...
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 ...
4
votes
4answers
267 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 ...
5
votes
1answer
270 views

Is it possible to use the Android layout system in a desktop java application?

I am lazy, thus, if possible, I would like to only have to design and program a UI once. If I want to create an App for Android and as a basic Java desktop application, is there a way to reuse the UI ...
1
vote
2answers
199 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
638 views

Robot in a grid

This was recently asked to someone I know. 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) (Down) A(i,j)--> A(i,i+j) (Right) ...
0
votes
1answer
154 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 ...
0
votes
5answers
340 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 ...
-1
votes
3answers
121 views

Complex Number help

OK so I have a programming assignment and I need to create a class that represents Complex Numbers (good so far), add them to a list(good so far), and then output whether each individual number is ...
11
votes
0answers
209 views

Haskell build and artifact environment similar to Maven

I used to be a Java developer for a long time, but recently, I joined a Haskell team. In the java world, if you have a large project, with several teams working on it, a common approach is to use an ...
2
votes
3answers
437 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 ...
0
votes
2answers
103 views

What naming convention should you use for data objects solely meant for parameters

This is my pseudocode for DAL: CusOrderDTO GetCustomerOrder(DateTime OrderDate, string customerCode) CusOrderDTO orderSet = new CusOrderDTO() * query data from database, populate CusOrderDTO ...
0
votes
1answer
97 views

Is there are any common pattern/practice to handle exception list (Java)? [closed]

Suppose I've got a sophisticated parser for something. And a I don't want Throw Early/Fail-Fast strategy. If I've got multiple problems, i want to have list of exceptions in my log file because I want ...
0
votes
1answer
92 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 ...
-3
votes
1answer
107 views

Java Start JNLP without paying to certificate authority?

I've noted that now it is difficult to run Java Web start files (JNLP) by Oracle for Java8, without a proper certificate, due to "security reason".It is breaking thousands of applications across the ...
0
votes
1answer
158 views

Injectable, Poppable Stack

Background A project involves converting a relational expression map (rxm) to an XML/SQL statement. The map resembles: root > people, # "root" keyword starts the document ...
2
votes
1answer
47 views

Can tools.jar from OpenJDK can be installed in public repository

Is it legal to install tools.jar from OpenJDK in public maven repository? I found at least three topics on the Internet which conclusion was that such action is forbidden for jar provided by Oracle, ...
4
votes
1answer
115 views

Should I implement the consumer/producer pattern in my java video app, and if yes, how?

I built a small video frame analysis app with desktop Java 8. On each frame, I extract data (5 doubles now, but could expand to a 1920x1080x3 OpenCV Mat in the future). I would like to store this data ...
-4
votes
1answer
42 views

Create a main method to run the below code [closed]

I'm learning Java. I wonder how to run the below code? public class Test01{ public interface Printable{ public void print(); } public class PrintRectangle implements Printable{ public void ...
1
vote
1answer
143 views

Hypothetical : What restrictions will I need to add to Java so that I can remove its GC? [closed]

This is a hypothetical, yet very technically precise question I'm trying to ask all the compiler/static analysis programmers. I'm trying to understand the extent of prohibitive features I would need ...
2
votes
4answers
105 views

Single method with many parameters vs many methods that must be called in order

I have some raw data I need to do many things to (shift it, rotate it, scale it along certain axis, rotate it to a final position) and I am not sure what the best way to do this to maintain code ...
4
votes
4answers
262 views

Styleguide when coding in a static language [duplicate]

I am currently a junior engineer and keen on learning best practices and expanding my experience. My question concerns any static programming language such as Java, C#, C++ etc. When I am writing ...
1
vote
2answers
103 views

MVC like design with interfaces: How to handle basic objects?

I have an (android) application and decided that the presentation layer will get data only through strict interfaces from the controller. I am at the point where some basic objects need to be passed ...
1
vote
0answers
136 views

Java write to text file from multiple threads

I have a thread which read and insert new lines in same file. I must synchronized that file so that no other thread is not accessing the file at the same time. Here is how i will synchronize a file ...
15
votes
3answers
1k views

Which version of Java should I use for a desktop application to reach the most users? [closed]

Am I correct to assume that most end users are using an older version than Java 8? Since I do not want to force people to upgrade in order to use my application, should I plan it to use Java 7 or even ...