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
0answers
73 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. ...
1
vote
2answers
193 views

When should we work on GC optimization?

So, I've learnt about how GC works and how can I monitor it via VisualVM, but my question is about why we should ever perform GC optimization? In our web project (JSF/Spring/Hibernate) we haven't ...
-1
votes
0answers
38 views

Persisting state of current execution in Java

I have specific use case, and I'm looking for opinion and suggestions on implementing this in Java as I'm fairly new to this. I have a dependency graph kind of process. The entity E in the processing ...
-2
votes
2answers
136 views

Why public access level method get overridden in java?

This question is raised with a clarification required to decide when to declare a method protected or public during class design of a package. My point is, if one needs to override a method of a ...
0
votes
2answers
159 views

Java card game design decision

I am making an application for a card game, with a standard 52-deck playing card. For now, I am writing a solitaire game with for learning purposes. I've had some experience making platformers and ...
4
votes
3answers
232 views

Why use arg type `class Object` instead of `Comparable[]`?

In the code below, I believe it would look more appropriate to make the method argument be of type Comparable[] instead of Object[]. The first reason it would be more appropriate is that one can be ...
0
votes
1answer
106 views

Is it possible to have a keyed dictionary stored on disk? [closed]

for example) would it be possible to be able to use the key of an item to access the item stored in a file out on disk (without searching through the whole file)? I'm looking fora general example of ...
0
votes
1answer
67 views

Matrices calculations on partial shape matching

I'm working in a shape recognition project where it is supposed for me to develop an application that receives two images: an original one and a sketch made by a user. I am supposed to detect contours ...
0
votes
2answers
145 views

Develop GUI and logic in a team the right way? [closed]

I am planning to start a small project with a friend. I will be developing the GUI using JavaFX in the MVC pattern and he will be responsible for the model/logic. My question is: how can we achieve a ...
0
votes
1answer
23 views

Using classes not designed for multiple sessions in servlet

I'm looking for a way to use a collection of Java classes in a servlet, which would provide some services to clients, but the classes were not designed with multiple sessions in mind, which seems to ...
0
votes
1answer
69 views

Can JUnit be used to test this project?

I currently have an interesting situation occurring with my code, and after hacking away at what turned out to be a dead end for the last two weeks, I'm here asking those smarter than I to educate me ...
2
votes
1answer
103 views

Is Singleton enough for a EMailUtil or there is any better implementation? [duplicate]

I am developing an application, where I have to send lots of emails for user account creations, validation, invites etc. I have implemented a static class EMailUtil which has different methods like ...
-1
votes
0answers
46 views

Java - Can't call an Array from a different method [migrated]

I've been a long time lurker, and I've come across a part of my code I cannot figure out even with the help of stackexchange. I can't seem to call an Array from another method of mine. I have a bunch ...
2
votes
1answer
53 views

Creating/updating entity save strategy

Please note: although I'm talking about Java in this question, what I'm asking about here should really be language-agnostic. I am dabbling in OR/M for the first time, and have cooked up the ...
2
votes
0answers
69 views

is there a way to tell JDBC I am about to execute a transaction? [migrated]

when setting AutoCommit to false; is this means that I have to commit after executing every sql command in my application. here is a scenario SQL1 doesn't need to be a transaction. SQL2 needs to ...
0
votes
0answers
36 views

Programmatically extending table/entity definition mappings through aspects in Spring and Hibernate

I would like to know if it is possible to use 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 with ...
-2
votes
0answers
48 views

What is the best way to store user uploaded Java files? [duplicate]

I am working on a website where users can upload their own Java files, and we will later compile and execute them. I will address the risks of executing users' code separately, but what would be the ...
2
votes
4answers
221 views

Why is the hashCode method usage of HashSet not specified in the API?

I was trying to debug my code which uses a HashSet and searching through the SO, I found out that I needed to override the hashCode method as well. The strange part is, checking the related API, I did ...
1
vote
2answers
94 views

Improve the speed of a Tomcat Server with MySQL

I'm developing an application with 3 sides, desktop (JavaFX), server (Tomcat) and Android. And a MySQL Database Server. The app receive mails and convert them into tasks. The tasks are sent to the ...
1
vote
1answer
124 views

Creating a calendar/planner program. Confused about OO logic?

I'd like to create a piece of software that has the functionality of a common written planner. To do this, it will have a Calendar. When planning the program, I became confused as to how I would ...
-1
votes
0answers
102 views

How do i wait for all threads in java code here? [migrated]

I would like to compare thread performance on solaris/linux/windows 64 bit JVM's, with the below code. I personally, prefer this style of coding for threading, because you have a method performing ...
0
votes
3answers
171 views

Building a calculator using MVC

I've been programming in Java for about 6 months, and I thought a good and challenging test of my skills would be to build a GUI calculator. I have very recently heard about this MVC idea, and I ...
0
votes
2answers
85 views

Managing multiple JDBC connection

I have an application that connects to databases based on a json string that contains connection information. The json is sent just when the application starts. How do you manage such connection ...
0
votes
1answer
135 views

Is Default Package included in the Package Level Access?

I would like to know how the default package is defined in Java.I know how public and private access is defined but I don't know whether there is any default package access that is defined in package ...
-1
votes
1answer
182 views

Whether Methods could be defined in Constructors in Java? [closed]

I am learning to program in Java and have run into a situation I don't understand. I have this code import java.io.*; class temp { temp() { Finish f=new Finish(); f.end(); } ...
-2
votes
0answers
146 views

Trying to create the simple 24 game in java, I have some code but I need to reverse it [duplicate]

I am trying to create the 24 game in java and I found some code that does what the game is supposed to do. This code give the user 4 numbers and the user then has to put them into an equation to equal ...
-3
votes
1answer
62 views

Why are there just a few implementations of a Java EE container? [closed]

I see at the JCP that work on Java EE 8 is allready in progress, as Java EE 7 was released almost 1,5 year ago. However, as far as I know there are only three implementations of the Java EE 7 ...
0
votes
0answers
7 views

What is first argument in 'JOptionPane.showConfirmDialog() here? [migrated]

Here is the below code snippet, where i would like to display the dialog using JOptionPane.showConfirmDialog() by setting its parent as resultsTablePanel: public class SearchResultsTablePanel extends ...
-3
votes
1answer
116 views

What is immutable by default in Java? [closed]

While trying to grasp copying/copy constructors, and noticed that some things seem to be immutable by default (Strings, and Integers), while everything else is mutable by default. That leaves me ...
3
votes
2answers
118 views

What preconditions should be checked while adding/removing a listener?

Imagine the following interface: interface Service { addListener(Listener l) removeListener(Listener l) } Should I check for null values while add/remove? Is it a good idea on remove to ...
3
votes
0answers
109 views

What is the advantage of 'SwingUtilities.invokeLater()' method?

For the below sample GUI program using javax.swing, public class UnResponsiveUI extends JFrame{ private boolean stop = false; private JTextField tfCount; private int count = 1; /* ...
0
votes
2answers
185 views

Using Constructors in Java

I would like to know why do we need to use constructors in examples like this:http://math.hws.edu/eck/cs124/javanotes5/c5/s2.html. I think even if there are no constructors the programs mentioned in ...
0
votes
0answers
24 views

What does 'name' attribute signify in any java.awt component?

With the below program, am trying to find the names assigned to all the components part of the GUI. public class AWTCounter extends Frame implements ActionListener{ private Label lblCount; ...
-2
votes
0answers
28 views

Why 'JRootPane' is-a 'JComponent' in javax.swing? [duplicate]

As per below code, I see that, setLayout() is being called on a JRootPane object instead of JFrame top level container in javx.swing world unlike java.awt, because it is told that swing's JFrame is ...
1
vote
1answer
95 views

Java App as Tomcat Service?

I currently have a basic j2ee website. Currently, a jsp frontend gets data from the backend (the java program, lets call it object "Score"). The backend gets this data from a web site. <% Main m ...
3
votes
1answer
89 views

Why 'JButton' is-a 'Container' in javax.swing?

As per the class hierarchy in java.awt.*, class Button & class Label is-a class Component, and Component is not a Container, which make sense to me. As per the redesign of class hierarchy in ...
0
votes
1answer
20 views

Query on usage of 'Window()' default constructor from java.awt

I had been through this query before asking this question. In class Window we have constructor with default direct access level package private but not private as shown below: Window() throws ...
1
vote
4answers
127 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 ...
3
votes
1answer
163 views

Type Casting in Java

Could anyone explain why short(100000) is -31072 as said in p.48 of java-notes.The article says that "the value -31072 is obtained by taking the the 4 byte int 100000 and throwing away two of these ...
1
vote
2answers
168 views

Most Efficient way to Compute the sum of divisors of N (1 ≤ N ≤ 1 000 000 000)

I want to write a code which computes the sum of divisors of a number N(1 ≤ N ≤ 1 000 000 000), excluding the number itself. However, I need an efficient way to do it. It suppose to print the answer ...
1
vote
2answers
52 views

Query on Recursive composition

For the below relation between Container and Componentin java.awt class hierarchy, I see that, in addition to is-a relation, class Container has composite relation with class Component with below ...
0
votes
1answer
76 views

Does class Availability makes programming as Object Oriented Language? [duplicate]

Does class Availability makes programming as Object Oriented Language ? Most of the people think that if there is Availability Class in a language, then that language becomes Object Oriented. Is it ...
2
votes
2answers
188 views

architecture of database heavy application

A program I'm currently designing is extremely database heavy, almost anything the user does will alter the database, or read from it. Now I have one interface which defines all these operations, and ...
0
votes
1answer
99 views

Starting Execution of Java Program [duplicate]

While reading about Java Programming I couldn't get why it states Java static main necessity reason is because "before you're program starts,there aren't any objects to send messages to" as said in ...
0
votes
6answers
226 views

Why 'String' objects are immutable with an explicit constructor in java? [duplicate]

It make sense to make class String objects immutable with following declarations, because they share the same storage in common pool. String str1 = "abc"; String str2 = "abc"; But, am not sure, if ...
0
votes
0answers
9 views

What is meant by end of stream reached in inputstream.read()? [migrated]

my android smartphone is tcpclient and chipkit wf32 wifi module is my tcp server. int bytesRead; InputStream inputStream = socket.getInputStream(); while ((bytesRead = inputStream.read(buffer)) != ...
0
votes
2answers
266 views

Where is it specified that Java is call by value?

I know that Java is by default call-by-value but I am not sure where in the Java Language Specification this is addressed. Google searching only seems to find me unofficial sources but never points to ...
0
votes
0answers
33 views

Transaction Management in Hibernate with DAO Design Pattern

I have many Tables, For every Table,we have DAO Interface and DAOImplementation class. Example DAO Interface public interface CancelPolicyDAO { public CancelPolicy insertCancelPolicy(CancelPolicy ...
1
vote
2answers
169 views

Are there other ways to limit recursion depth for a function?

I am trying to prevent a function/method (in Java) from performing recursion more than a depth of 3 self calls. I've learnt about the accumulator trick from odersky's scala coursera course. public ...
11
votes
4answers
575 views

Why shouldn't a method throw multiple types of checked exceptions?

We use SonarQube to analyse our Java code and it has this rule (set to critical): Public methods should throw at most one checked exception Using checked exceptions forces method callers to ...