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

45
votes
10answers
15k views

Why is String immutable in Java?

I couldn't understand the reason of it. I always use String class like other developers, but when I modify the value of it, I need to create new instance of String. What might be the reason of ...
0
votes
0answers
23 views

Is this code Clean, Effective and SOLID? [migrated]

I've recently read the books Clean Code and Effective Java. I am a huge fan of Object-Oriented Java. I am trying to write as professionally as possible. I have been an Android Developer for 20 months ...
5
votes
3answers
179 views

Is it conventional to name final/constant local variables in UPPER_SNAKE_CASE?

Pretty simple, I have a method: public final void myMethod(User user, Group group) { final int MAX_USERS_PER_GROUP = group.getMaxUsersPerGroup(); int usersInGroup = 0; // Get users in ...
1
vote
1answer
432 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 ...
-5
votes
1answer
57 views

Extends a class and have its method called automatically [closed]

I have a starting class that extends a class that initializes it. It doesn't seem to call any of the initilalization code though. Basically I have this core class: public class blender { public ...
0
votes
2answers
396 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 ...
16
votes
4answers
13k views

Why are nested loops considered bad practice?

My lecturer mentioned today that it was possible to "label" loops in Java so that you could refer to them when dealing with nested loops. So I looked up the feature as I didn't know about it and many ...
2
votes
1answer
91 views

Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?

I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
27
votes
6answers
4k views

Dynamic Code Evaluation in Java - Clever or Sloppy?

I am trying to create a flexible ACL framework in Java for my application. Many ACL frameworks are built on a whitelist of rules, where a rule is in the form of owner:action:resource. For example, ...
3
votes
1answer
128 views

Recursively parse without resorting to ugly design patterns

I'm currently building a crochet pattern parser in Java, and I've hit upon some trouble. I'll call the language used for input Crochet Pattern Code (CPC). I have a rather large writeup on the ...
0
votes
2answers
58 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 ...
2
votes
0answers
62 views

Fixing years of bad coding [duplicate]

Last year I got my first job with an I.T. company developing industrial Android applications. Unfortunately, when I got there and started working with the code base I was repeatedly confronted with ...
2
votes
2answers
66 views

Creating an auto-patching system for Spring Hibernate Application

I have this question for few months now. We have a web application which has monthly changes and weekly bug fixes if any. Usually we just build the new war, undeploy the old ones and redeploy new ...
2
votes
1answer
238 views

Large Scale Application Development in Android

Since, I am fairly new to large scale app development in Android and Java, I thought I would ask for advice. My team is faced with developing a prototype of a fairly complex medical software. ...
6
votes
6answers
561 views

Why are my unit tests so expensive? [duplicate]

I am a Java developer, working on a small project. We are three people in the team, we have a budget for 3 months of coding (+ some time for the Analyst, Project Manager and QA team). It is a small ...
-5
votes
0answers
66 views

Breaking out of an for statement in Java [migrated]

If i do something like this boolean ret; for(int i = 2;i<30;i++) { if ( 30%i == 0){ ret = true; } else { ret = false; } } ret becomes true allready at 2, but also at 5,10 15, is ...
0
votes
0answers
29 views

handling external events in a cluster environment

I have an app written with JSF and Spring using JPA+Hibernate which is running on a Glassfish4 server. Right now I have an Observer pattern which is listening for some Postgresql events. Let`s say ...
-1
votes
1answer
1k views

What is meant by Distributed Systems Coding interview questions [closed]

I was told that I will be asked coding questions in my interview and that the context will be related to Distributed Systems (I took ONE Distributed Systems course and I don't even remember much from ...
0
votes
0answers
4 views

Help with removing circles from javafx pane when clicked [migrated]

I have an assignment for school where i have to make a pane and then make circles appear when i click them, and then remove them with right clicked. this is what i have so far ...
0
votes
1answer
92 views

How to structure programs that interact with databases? [closed]

I've just finished a book on MySQL and I'm in the infantile stages of learning to couple that with Java. I know that the technology I need to learn is called JDBC and that it essentially allows you to ...
7
votes
3answers
1k views

What is the difference in memory between a variable assigned to null and one not assigned

What is the difference in memory between a variable assigned to null and one not assigned? I know that there is a difference in usage, but what is the difference in memory?
0
votes
1answer
361 views

Spring web application deployment infrastructure

I'm interested in hearing out what's out there in terms of tips and tricks on deploying and maintaining a Java web application whilst keeping agile. I'm running solo on a startup project I'd like to ...
-4
votes
1answer
65 views

improve optical character recognition of image using Tess4J [closed]

How to improve optical character recognition of image using Tess4J ? Some case have unstable result especially when you have text inside image. there is my code : try { ...
0
votes
1answer
92 views

Possible way to make java class builder more abstract by using interface required keys

I'm looking for a more abstract pattern for builders that handles required fields without the need of writing a validator that checks if all requried fields are set. I like this builder. But is ...
4
votes
1answer
103 views

Parking Simulation Software Design

I've been requested to develop a quite well known problem for a job interview. The Parking Simulation which an example can be found here. I came up with some ideas for which design pattern should I ...
2
votes
5answers
469 views

Is there an alternative to instanceof when filtering a Java stream by class?

I have an unexpected situation in a project in which all types extending one class are packed into a Java collection; but only a specific extension of that class contains an additional method. Let's ...
4
votes
4answers
260 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 ...
0
votes
0answers
13 views

Is Java JNLP codebase entry required in the jnlp tag? [migrated]

I have an applet that needs to be served from 50 different servers in an M2M network. The following line in the jnlp file will work <jnlp spec="1.0+" ...
0
votes
1answer
70 views

Making a database and related operators using files and JSON in java [closed]

I'm trying to write a program that reads operations from a file. these operators look like below : CREATE TABLE student(id:integer, gpa:decimal, name:string, family:string,isMale:Boolean) INSERT ...
0
votes
1answer
39 views

Reading from html page that needs cookies passed and form data

I am writing a program in java in order to practice tough coding problems and learn more. Program description The program reads first names from a text file one by one, then enters them into facebook ...
3
votes
1answer
332 views

Scheduling a few CPU-intensive tasks

I need to schedule a small number of CPU-intensive tasks to run every so often, reading from shared data and writing to dedicated buffers. I don't necessarily want to roll my own scheduling, but am ...
0
votes
1answer
338 views

MVC: How to Implement Linked Views?

I'm developing a java application to visualize time series. I need (at least) three linked views, meaning that interaction with one of them updates the others. The views are: A list represents the ...
0
votes
1answer
157 views

Should I always call super in Java? [duplicate]

Anti-pattern considerations aside, should I always call super in Java when overriding methods, even when the method is empty? Take a look at the code below, this is an excerpt from AsyncTask and can ...
1
vote
2answers
238 views

A 'task' system which has an ending, to get ready for next task

I want to make a system, so that there are certain tasks. For example, let's talk about a game. I want to make it so there are 100+ tasks doing different things, but when the player's magic level is ...
0
votes
2answers
227 views

How to manage data flow between UI components?

I have been trying to use classes that implement ActionListener to respond to user input. I'm consistently noticing that for an action listener to communicate the event to other objects, it has to ...
0
votes
0answers
37 views

Spring Boot Hibernate and JSR 303 - response formatting [migrated]

Sifting through forums I can't seem to stumble into an issue solution I've been haveing with Spring Boot + JPA and JSR303 bean validation. Simply put validation works but but when say ...
2
votes
1answer
263 views

DataMapper for a MMO game plugin to send packets

I am working on an plugin for some game-server. The information about the plugin is not really necessary. Few points you might find helpful to answer to this question: The server The server is ...
1
vote
1answer
80 views

Non-fixed-size Fenwick Tree implementation

I'm planning to implement a non-fixed-size Fenwick tree. That is, a Fenwick tree that allows interleaving range queries with adding/removing elements. All implementations and samples I've seen so far ...
1
vote
2answers
94 views

Pattern for validating rules having different signatures

I have a class in charge of responding to an input event and maybe triggering another event. To decide, it has several rules to check. I'm trying to get away from a class looking like this: public ...
0
votes
0answers
4 views

Java j2ee JSTL cannot print a list of objetcs [migrated]

i'm currently working on a small Java J2E project. I want to print a list of objects in a *.jsp page, but there's an error i can't seem to get rid of. My .jsp page : <%@ page language="java" ...
0
votes
2answers
432 views

Is factory pattern a right pattern for the situation described here?

Is factory pattern a right pattern when we want to consolidate the related objects? Problem - In the Set-top box, I have a user-io, basically the interface to control the settop box - The user-io can ...
-2
votes
0answers
14 views

Java Robot class highlighting text help [migrated]

I'm trying to write a program that copies text from TinyChat(https://tinychat.com) and copies it to the clip board. Eventually it will take everything said in chat and paste it in Skype. Every message ...
2
votes
2answers
125 views

When to use ANTLR and when to use a parsing library

I've always wanted to learn how to write a compiler - I've decided to use ANTLR, and am currently reading through the book (its very good by the way) I'm pretty new to this, so go easy, but the jist ...
0
votes
1answer
90 views

Architecture for my Java application [closed]

I try to create small Java tools to help me at my work every now and then. Usually these do not have to be pretty and I find myself coding a single, sometimes massive, Java class. However, now my plan ...
1
vote
1answer
161 views

Debugging xml and annotations

By now, most web containers have an annotation variant of their xml configurations for Java EE. I'm guessing this is because it's better to keep things in Java where they can be managed, coded with ...
0
votes
1answer
419 views

Dynamic query in MySQL

I'm doing a J2EE web application with Struts2, MyBatis and a MySQL database, so what I want is to allow the user to be free to choose different parameters to perform a select to a table in the ...
2
votes
1answer
68 views

Advantage of Declaring and Initializing Different Object types?

I am learning how to use java to program, and am just learning about abstract classes and how they are useful. Say I have a class which extends another abstract class, which has 2 methods, one of ...
1
vote
1answer
226 views

Is this database design good? What JPA Entities should I create for this design?

I am trying my hands on JPA. For this I am thinking of using the example of a student admission process as shown in the diagram below. Is this design good ? Any suggestions for improvement are ...
0
votes
0answers
52 views

What are the different types of whitespace referred to by Perl? [migrated]

I am trying to find the Java equivalents of the Perl regular expressions not supported by Java. These are, as listed in the Java Documentation: \h A horizontal whitespace \H A non horizontal ...
1
vote
1answer
37 views

DataThread class that doesn't extend Thread, poor naming?

I created a DataThread class that doesn't extend a Thread, but has one as a member variable. Favor composition over inheritance, is a rule that I heard of, but I am thinking that the name of the ...