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

0
votes
1answer
99 views

Dynamic query in Mysql

I'm doing a J2EE web application with Struts2, Mybatis and a MySQL database, so what I want to allow to the user is to be free to choose different parameters to perform a select to a table in the ...
1
vote
3answers
142 views

w3c library license: does it prevent the inclusion in/distribution with paid software?

From W3C Software Notice and License: Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is ...
0
votes
1answer
57 views

Database Password problem when using GIT to manage project that uses Spring to initiate Datasource

Program Situation I use Spring Framework to code my Web Service, using Dependency injection to inject a DataSource bean into the DAO bean that will be used by the Web Service. I have all the ...
4
votes
1answer
368 views

In Java, why use bit hacks when non-bitwise technique it is more readable?

Is there any legitimate use for bit manipulation hacks in higher-level languages such as Java? I can see them being useful in speed-sensitive low-level and computation-intensive programs, e.g. ...
0
votes
1answer
70 views

DTO - service layer - statelessness best practices interfering with each other

I am designing a REST API coupled with a service layer that takes DTOs as input and produces them as output. This works fine for most service calls where the DTO is used to access an underlying ...
2
votes
1answer
169 views

How should object identification be managed?

I have a java/swing application in (hopefully good) MVC structure. Here is a overview of my model classes: One or more workers may work at one working location and one worker may work at different ...
31
votes
6answers
2k views

Good or bad practice to mask Java collections with meaningful class names?

Lately I've been in the habit of "masking" Java collections with human-friendly class names. Some simple examples: // Facade class that makes code more readable and understandable. public class ...
17
votes
4answers
668 views

How can I use unit tests and TDD to test an app that relies mostly on database CRUD operations?

At work, one of my projects is mostly about taking data passed in from an external client and persisting it in a database. It's a Java enterprise app using JPA and most of our logic revolves around ...
1
vote
2answers
119 views

IllegalStateException vs. IllegalArgumentException

In have written a function which expects the caller to pass in a configuration file like XML. Then I parse this given file and extract something which i then return. In this function (at least) two ...
0
votes
0answers
8 views

EBeans alternative to find() in JPA [migrated]

I was following the Play! Framework tutorial on creating a blog. They use JPA instead of EBeans and they use the find() function that extend from play.db.Jpa.Model . I am using EBeans and have ...
-5
votes
3answers
78 views

On checking with == with value 1000 answer is coming different but giving the object value 5 answer is same. Can anyone explain the ambiguity [closed]

public class equalsCon { public static void main(String[] ) { Integer obj3 = 1000; Integer obj4 = 1000; if (obj3 == obj4 ) System.out.print ("Equal"); ...
-4
votes
1answer
178 views

High level languages compared with visual programming environments [closed]

Could I have a professional view on the effectiveness of visual block-based programming environments ( a program such as 'blockly' or 'scratch' or 'app inventor') in comparison to high level ...
0
votes
1answer
98 views

Is Akka a good solution for a concurrent pipeline/workflow problem?

Disclaimer: I am brand new to Akka and the concept of Actors/Event-Driven Architectures in general. I have to implement a fairly complex problem where users can configure a "concurrent pipeline": ...
40
votes
7answers
3k views

Why is the finalize method included in Java?

According to this post, we should never rely on the finalize method to be called. So why did Java include it in the programming language at all? It seems like a terrible decision to include in any ...
0
votes
1answer
66 views

Implement RPC via SIP

Look at the following use case. I have a client (Java) application, which wants to get/set the state of another, remote application (C). The communication between them is done via SIP, which is run ...
25
votes
9answers
2k views

Is template “metaprogramming” in Java a good idea?

There is a source file in a rather large project with several functions that are extremely performance-sensitive (called millions of times per second). In fact, the previous maintainer decided to ...
0
votes
0answers
31 views

Overriding JDK classes [migrated]

I want to override the JDK implementation of sun.nio.ch.SocketChannelImpl so I have access to the FileDescriptor and can create a second SocketChannelImpl with an existing FileDescriptor. I can't ...
0
votes
3answers
265 views

Why do APIs generally consist of interfaces? [duplicate]

I am starting out in Java API design and in reading existing code bases, I have found that most APIs consist of interfaces only with their implementations bundled in a different package. Having read ...
-1
votes
0answers
38 views

Concept to Transfer Rater per Second while downloading [migrated]

i am being given a task from my senior to come out with a function to show size transfer rate per second. I have to download a file from web with my java code and display the transfer rate per ...
21
votes
8answers
3k views

Is it an antipattern, modifying an incoming parameter? [closed]

I am programming in Java, and I always make converters sort of like this: public OtherObject MyObject2OtherObject(MyObject mo){ ... Do the conversion return otherObject; } At the new ...
2
votes
4answers
284 views

Is it possible to have a single code base for a desktop GUI and a web application?

The required user interface is fairly simple; basically, two tables that "interact with each other", e.g. certain rows in one table get highlighted when a row in the other is clicked, plus maybe a ...
3
votes
2answers
229 views

Is the Java Integer cache a realization of the object pool pattern?

One of the best-known examples of a full-fledged object pool is the JDBC connection pool. Main reasons: objects in the pool are expensive to create and relate with external resources each object in ...
2
votes
3answers
234 views

Transitioning from Java & C to C++

I learned Java and I'm pretty competent programming in it. I also learned C recently. I looked at a comparison between Java and C++ and I like C++'s features like operator overloading and its speed. ...
0
votes
1answer
64 views

How can I use guice to replace code dependent on service locator implementation?

Consider I have a service called FileSystem, and that this FileSystem is used by various classes throughout the application. Typically, the service is acquired via some static class method ...
3
votes
1answer
78 views

Defining a random “safe” path for a game character

I am writing a game in Java and it can be likened to the recently popular game "Flappy Bird" in the sense that the character moves up and down and the users touch and must avoid the obstacles. The ...
1
vote
4answers
172 views

How to ideally calculate profit margin with zero sales

How do you handle the following scenario without null? You have this problem (In Java): BigDecimal sales = ...; BigDecimal cost = ...; BigDecimal profit = sales.subtract(cost); // Profit Margin = ...
0
votes
0answers
48 views

Dynamically add/remove components to/from panel

I'm in a little planning phase of my java/swing project. Here is a picture: It is a main panel containing several sub panels depending on the selected date in the top center. I want to browse those ...
0
votes
1answer
44 views

Broadcast receiver Or Services

I am creating an "Alarm Clock" app in Android. I learned that we can implement OnReciever() method and write those things which we want the alarm to do after an intent is fired. But I have now come ...
0
votes
1answer
145 views

Complexity of ArrayList of LinkedHashSet

I get input strings from the console like this: while ((currentLine = bufferedReader.readLine()) != null ) { StringTokenizer string = new StringTokenizer(currentLine, " "); while ...
0
votes
1answer
118 views

problem on calculating Big O complexity

i have this function on which i have to calculate the time complexity with the Big O notation: public void print(ArrayList<String> operations, ArrayList<LinkedHashSet<String>> ...
-1
votes
0answers
18 views

Struts forms still empty [migrated]

I am beginner developer and i'm working on a web application in Java whith struts. I have a problem with my struts form which stay empty after user enters informations. I've tried many way to resolve ...
0
votes
3answers
105 views

How to get an image or rectangle to detect collision with another image

Can someone please explain to me how to detect collision with another image? The tutorial I was watching explained how to detect if a collision occurs between two rectangles but I would like to use ...
2
votes
1answer
147 views

Working with a large, messy object [duplicate]

I have been handed a very cluttered, "One Ring" object (one object to rule them all). The OR class has 40 fields. These fields map to 16 different objects (the OR has all the fields from the 16 ...
40
votes
5answers
6k views

Why was C# made with “new” and “virtual+override” keywords unlike Java?

In Java there are no virtual, new, override keywords for method definition. So the working of a method is easy to understand. Cause if DerivedClass extends BaseClass and has a method with same name ...
-2
votes
1answer
84 views

What is the best way to get a method name in runtime?

Here is a little background of my problem: I implemented a singleton logger class which is being called from several projects. I want to log the name of the class as well as the name of the method ...
-2
votes
4answers
224 views

What is the name of this design pattern? [closed]

I have been using this "design pattern" (may or may not be an "official" design pattern) for a while and I wanted to know if it had a name (so that I could name my classes after it). Example in PHP ...
0
votes
2answers
82 views

calculate complexity of LinkedHashSet

I have an ArrayList<LinkedHashSet<String>> setOfStrings for example this arraylist internally is composed like: positionX[hello,car,three,hotel,beach] positionY[.....] ... I want to ...
0
votes
2answers
69 views

Rectangle class java.lang.Object

Can someone please explain to me the difference or benefits rather to using the rectangle class ex. Rectangle r1 = new Rectangle(x,y,w,h); versus the graphics class drawRec method? ...
0
votes
0answers
13 views

How to get Datasource JNDI access to work with WebLogic reliably (no NameNotFoundException)?

in a WebLogic web application (bundled and deployed as a Jar) I sometimes get a NameNotFoundException when I try to fetch a datasource using JNDI lookup. The datasource is not shown in the JNDI tree ...
-1
votes
1answer
38 views

Swing component name suggestion for a specific interface [closed]

As a university project, I have to replicate Raptor. A flowchart interpreter. The interface looks like this But as I am not a experienced swing developer, I don't have much idea about which swing ...
2
votes
2answers
144 views

Is it better to draw my own graphics or import images?

I am about to start a Tetris clone using Java as my programming language. While I was designing how it'd be done, I've stumbled upon this question: What would be better, if any difference at all, ...
0
votes
0answers
4 views

js syntax errors in text adventure [migrated]

hi i'm new to java script and I wrote a text adventure for a school project and I keep getting these error when I try to run it js: "adventure.js", line 4: missing ( before condition js: if var ...
-3
votes
1answer
141 views

Can I use BOTH Java and C# in a game/application? [closed]

I am attempting to create something with friends, just a bit of debate over which language to use. This is not a debate over which is better, but can I use both in one application. And if so, how hard ...
-1
votes
0answers
25 views

android socket readObject EOFException [migrated]

In Android I make a siglenton pattern and when a send object the readObject the shows me the messaage: W/System.err(6034): Exception reading Streams: java.io.EOFException but when I put String I ...
6
votes
6answers
447 views

How to avoid downcasting?

My question is about a special case of the super class Animal. 1. My Animal can moveForward() and eat(). 2. Seal extends Animal. 3. Dog extends Animal. 4. And there's a special creature that also ...
0
votes
1answer
50 views

Sortable listview using SQLite [closed]

I'm implementing a sortable listview using bauerca's library here. This works, but now I need to define some things where I need some help. This is the functionality of my app_ I can create up to 5 ...
2
votes
0answers
236 views

Is it safe to convert Windows file paths to Unix file paths with a simple replace?

So for example say I had it so that all of my files will be transferred from a windows machine to a unix machine as such: C:\test\myFile.txt to {somewhere}/test/myFile.txt (drive letter is irrelevant ...
6
votes
3answers
372 views

What complexity do DI frameworks add?

The currently most upvoted answer to a very recent question states that DI containers are an "enterprise software" pattern, used when the object graph is very large and complex. I suspect that 95% ...
3
votes
2answers
242 views

I don't know how to understand the Wildcard type in Java

I am reading the Core Java (9th edition) by Cay S. Horstmann and Gary Cornell. After making an effort, I cannot still understand the ? super Manager. Here are some materials relating to this question. ...
1
vote
1answer
92 views

Reference wind directions to texture space?

I have a 2D array filled with a simple class: class Tile { boolean N,E,S,W; } I also have a tilesheet representing all possible outcomes except all false (12 + crossroad). Now i need to ...