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

-6
votes
1answer
70 views

Why ? Constructors cannot be declared as final? [on hold]

Why final keyword is not working with constructors in java? I'm a bit confused with this, but it works fine when declared with methods. What's the reason for that? class NewClass{ int speed = 40; ...
3
votes
1answer
109 views

Should a new type be created though it only wraps a single field?

Say I have an interface Species that's defined as public interface Species { String getId(); String getDescription(); } The question is simply this: Should I create different classes to ...
7
votes
4answers
738 views

Should Objects with lots of fields be broken up?

When I have an Object that has lots of fields is it better to have them all as fields or try to find logical groupings as their own Objects and make those the fields? I guess it comes down to which ...
5
votes
4answers
166 views

Is Java package level scope useful?

I understand the idea of package scope, and at times have even thought I wanted it. However, every time I set down with a serious intent to try using it I discovered it did not fit the needs I ...
2
votes
3answers
89 views

Responsibility of the small business logic: in a class or in a method?

I have separated business logic to many small blocks. Each block can be coded in small number of lines. Where should I put the block code? [A] in a method, grouped in the class by some same feature ...
-4
votes
0answers
60 views

What should I prefer for complex standalone Java desktop application [on hold]

I have a requirement. I need to build a bit complex standalone desktop application in java. It is complex in terms of functionality you can say hundreds of things can be done including database ...
1
vote
3answers
123 views

How can I create an abstract parent class which uses data from an inherited class?

I'm getting my feet wet with Android app development and tying to find a good way to manage database interactions across multiple similar objects. My goal was to have a structure like: public ...
1
vote
0answers
46 views

Detecting surface faces of a huge 3D mesh/grid

I've written a module in my application that creates a mesh from existing coordinate and face data. The number of vertices in the mesh could easily exceed 10 million and the same goes for the faces. ...
-1
votes
0answers
53 views

Backpropagation in layman terms [on hold]

I've been studying neural networks, and I'm beginning to understand the basics. I know what the backpropagation algorithm does. It feeds sample input and calculates an error against a given output. ...
1
vote
3answers
186 views

Would combining enums with static strings in java be sloppy?

Currently my team has a number of constants defined as static final strings. I want to be able to iterate over these strings as if they were an enum in one location, but everywhere else they are used ...
1
vote
1answer
83 views

What is the point of the dao layer? [on hold]

With the current technologies which are pretty good (JPA, Hibernate, others), what is the point of the DAO layer? It's very rare for a project to switch its backend from one vendor to another, so it's ...
0
votes
0answers
14 views

How should one model an ExchangeService object (in ews-java-api) for sharing MS Exchange connections?

I am creating an application which uses ews-java-api to connect to an MS Exchange server. Once the connection is authenticated, the api dictates use of ExchangeService object for searching mailboxes, ...
-1
votes
0answers
17 views

Segmented file downloading potential gains vs excess overhead/problems

I'm writing a download manager, i want to get as much speed as i can from my downloads and I'm thinking about implementing segmented file downloading with conjunction to parallel download for each ...
2
votes
1answer
42 views

Android Pass Data between fragments

I have a question about passing data using bundle between fragments. I need to pass the URL from a Product object to the next fragment, so I don't know which is the best approach: to pass only the URL ...
0
votes
1answer
73 views

Collections.sort question

My question maybe related to this question - Encapsulating Internal Data Structure I have a class LCTile.java which contains a Coordinate.java class. Coordinate.java that contains latitude and ...
0
votes
0answers
39 views

Securing HTML/JavaScript only web app / JAX-RS Backend [closed]

I am prototyping a small web app where the frontend will be a pure HTML+JavaScript+JQuery which consumes services from a JAX-RS backend. The application has started to have a shape now but I find ...
3
votes
2answers
171 views

Converting static utility class into singleton

In company where I work we have lots of "utility" classes, each has lots of code inside (thousands of lines), and they are all static. And one static methods call anothers. The problem here is that ...
-4
votes
0answers
69 views

How does HashSet in Java remove the duplicate elements [closed]

I know that the HashSet consider whether to add the element by checking if there is any equal one to prevent duplication. This is done by checking the equals() and hashcode() function. However, I am ...
0
votes
0answers
47 views

Approach to process data and store json into mongodb - creating a website functioning on java servlet backend [closed]

I'm not asking anyone to write code for me. I'm starting a project and I am looking for some advice. There are some practices regarding web development and databases that I'm not familiar with yet. ...
-4
votes
1answer
148 views

Comparing the Java language to non-Java JVM languages [closed]

I was contemplating on the necessity of different non-Java languages coming up on the JVM. Apart from syntactic sugar and built-ins, does any of them actually exploit some corner of the JVM, which has ...
-1
votes
2answers
128 views

Modelling a parcel management application

Scenario/Context: I am working on an application which would find out the highest volume of parcel delivery based on the pin code of a particular area by reading a text file which has the list of ...
1
vote
1answer
97 views

Porting security from Java/.NET to PHP

This probably a rather naive question given my limited knowledge in the code I've been looking at, but I want to get my head around it before I start diving into writing actual code myself. I'm ...
4
votes
3answers
152 views

Track Bug fixes in code

I am working in a project in which at many point I need to change the code and fix the bug of the system but how can I inform other team members about this change? Usually I add single line comment to ...
-1
votes
0answers
103 views

What is abusing static? [duplicate]

Many people are always telling me not to abuse static in Java. What does that mean and why should it not be overused? The most recent case where I was told not to abuse static came when coding a ...
4
votes
1answer
89 views

How to load environment configuration

In Java the typical way of storing configuration is by using property files. So I have several such files, one for each environment type (dev, test, prod, ...). This configuration is needed in ...
0
votes
0answers
24 views

Android TranslateAnimation :: How to get the Speed of Mass Object

I'm currently having a project for making a springs-joint effect on android. And With two objects : A Mass Object A Springs (for hanging the mass object) And this link is my GIF animated of the ...
5
votes
4answers
280 views

Is using object of main class better than using static main method? [closed]

I have noticed in java programs at least, that people tend to prefer to start their programs by creating and instance of the class that contains the main method, and activating a non-static method ...
24
votes
8answers
2k views

Is there any practical way for a linked node structure to be immutable?

I decided to write a singly-linked list, and had the plan going in to make the internal linked node structure immutable. I ran into a snag though. Say I have the following linked nodes (from previous ...
1
vote
4answers
201 views

What are the differences between class variables and instance variables in Java? [closed]

I'm very new to Java and want to be difference between class variables and instance variables. For example: class Bicycle { int cadence = 0; int speed = 0; int gear = 1; } How are ...
0
votes
2answers
63 views

Implementing a component that provides interfaces in a component-based framework [on hold]

I'm currently trying to develop a small white box component-based Android framework, but I have a doubt about which is the best way to implement my components and interfaces. An architecture of one of ...
1
vote
0answers
45 views

Shenandoah for OpenJDK? [closed]

I am very interested in the Shenandoah "pauseless" GC slated for the Oracle JDK in 2016 (Java 9 or 10 I presume?). Moreover, I'm wondering whether Shenandoah would eventually become incorporated with ...
1
vote
0answers
78 views

When is it justifiable to use pair programming and when is it not? [duplicate]

On the software project I'm working there are 4 teams of 6 people. The project itself is a moderately complex distributed system, but the current user stories are mostly about implementing CRUD ...
0
votes
0answers
58 views

Selenium Testing w/ dynamically generated element id's: XPATH or CSS selectors?

Background: I'm an intern tasked with learning Selenium; my organization plans on having QA/Testing use it to simplify testing. We use JSF and WebSphere Application Server. One of the persistent ...
9
votes
1answer
136 views

How to keep code examples in javadocs up to date

I'm working on a small library that provides implementations of basic, well known string metrics. Mostly for my own education. So development happens whenever I've got a bit of spare time. Because of ...
3
votes
3answers
278 views

'Encapsulation Vs Performance' trade-off in a lockable linked list

Main purpose of encapsulation is to protect in-variants of any class(in java). Here is the complete code for class DList/class lockDList/class DListNode/class LockDListNode. class DList and it's ...
1
vote
0answers
114 views

How do I set a final field via a setter? [migrated]

I have the following abbreviated class: public class Employee { private final float pointPosition; public Employee(float pointPosition) { this.pointPosition = pointPosition; } ...
-1
votes
0answers
18 views

Problems with storing plain text and byte information in the same file [migrated]

I am supposed to develop a subsystem to store certain business data in a file and I am running into a problem, but first some requirements I have: It has to be 1 file for the entire data. The data ...
2
votes
1answer
132 views

Should I force the user to wrap the arguments, or allow them to pass in the data at the cost of having more arguments?

I have the constructor: public class Player { final private DoubleDuple position; final private DoubleDuple momentum; public Player(double xPos, double yPos, double xMom, double yMom) { ...
2
votes
1answer
64 views

Does declaring a field as final force redundancy in the constructors?

I have the following abbreviated class: public class Player { final private DoubleDuple position; final private DoubleDuple momentum; public Player() { position = new ...
0
votes
1answer
72 views

Performance of sharing single object with multiple threads in Java

In Java, if I create an object that has a method to do something, and I pass that object to multiple threads which call the method, is there a performance difference from creating an individual ...
2
votes
1answer
236 views

Testing private methods as protected

I was reading this answer about testing private methods and it mentioned several possibilities: extract methods as public to another class make them public separate the env of test and production ...
-5
votes
0answers
24 views

java.net.BindException: Address already in use: JVM_Bind [migrated]

Server Program: import java.io.*; import java.net.*; class Server{ public static void main(String args[]){ try{ ServerSocket ss = new ServerSocket(8080); Socket s = ...
1
vote
0answers
54 views

Threading strategies for a webservice implementation

If I am building a webservice/Web API for servicing requests, there are 2 threading strategies I can think of. I will explain this in terms of Java (though the question may be relevant for any other ...
7
votes
1answer
324 views

When was Java's 'qualified this' introduced?

I've only recently learned about the qualified this, and was curious as to when was it introduced in the language, as I've been using Java here and there for around 18 years. Oracle keeps only the ...
-4
votes
3answers
343 views

How can the containsKey() method of a Java Hash Table be O(1)? [duplicate]

I had a very large ArrayList in Java, and I often need to check if it contains a particular value. This has proven very slow. Then I discovered that you can use a data structure based on a Hash. ...
0
votes
0answers
18 views

Application settings/configuration storage-Preferences over Configuration file? [duplicate]

Is there any advantage over any of these? I have application that reads its initial configuration from Preferences rather then creating and writing into configuration file somewhere in users ...
21
votes
6answers
3k views

Should a method be forgiving with the arguments that are passed in? [closed]

Suppose we have a method foo(String bar) that only operates on strings that meet certain criteria; for example, it must be lowercase, must not be empty or have only whitespace, and must match the ...
1
vote
2answers
193 views

Why Java does not have a framework like Rails? [closed]

I am a Ruby on Rails developer and I like its simplicity and rapidness. On the other hand we need to use Java for some projects that we develop for our clients. My question is why (pure) Java does ...
-2
votes
0answers
21 views

RESTful web service in Jersey [migrated]

Im creating a RESTful web service through Jersey. I followed the guide http://javapapers.com/java/restful-web-services-with-java-jax-rs-using-jersey I created the web service as mentioned in the ...
0
votes
1answer
71 views

Why are Strings in StringPool considered insecure?

Passwords are recommended to be stored in char[] instead of String, as Strings are stored in StringPool. Read more here As per this question Strings in StringPool are not available directly. To ...