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
12 views

Efficient way to find the source code of a given gialog in Java [migrated]

I am working on a Java app with some 100K lines code base. Searching for the source code of a given dialog is tedious. Searching by text is impractical because dialog title and button names are very ...
14
votes
2answers
7k views

Why should a builder be an inner class instead of in its own class file?

Many Builder Pattern examples make the Builder an inner class of the object it builds. This makes some sense since it indicates what the Builder builds. However, in a statically typed language we ...
1
vote
2answers
62 views

How to update Cache in Java while updating database tables directly [closed]

I want to update Cache in my java program when a row updates in my oracle database table. Is there a simple solution for that?
1
vote
1answer
65 views

Eventing solutions for java legacy applications too old for real JMS queue/topic eventing?

What are some architectural solutions that can mimic eventing for systems (Java) that are too old to implement eventing solutions, such as conventional Queue/Topic based JMS messaging? I have a ...
6
votes
6answers
14k views

Working with static constructor in Java

I didn't get a complete understanding of static constructors in Java. If it is allowed, why it is allowed? In what scenarios would you use it? What purpose would it serve? Can someone give me a simple ...
1
vote
2answers
108 views

One application's methods invoked by many other applications

I have a small Java console application that runs a set of data through an algorithm. Given the size of the data and compute time, I often run 10 to 15 instances of the application, each working on a ...
1
vote
2answers
99 views

When interacting with an ArrayList over REST will a ReadWriteLock maintain consistency?

I have an ArrayList of objects that may be added/deleted/updated via REST calls. In order to prevent issues that may result from concurrent accesses, will a ReadWriteLock be appropriate, and efficient?...
-4
votes
3answers
408 views

Why different languages have different syntax? [duplicate]

Different programming language always/most of the time use different syntax. For example take PHP, Java and Python. In Php & Java semicolons are compulsory at the end of the line, yet Python ...
-3
votes
0answers
62 views

How to deal with concurrent accesses to ArrayList? [duplicate]

I have an ArrayList that stores some data about users. Users can be created, deleted, and updated via REST calls. How do I ensure concurrent accesses to the ArrayList are consistent?
-1
votes
2answers
189 views

Java - Does extending a class which itself extends a class which itself… and so on… is healthy..?

NOTE : Feel free to edit the title if it is somewhat different than my question. In one of our application, we are maintaining a lot of properties inside Instance object. Obviously it's maintained as ...
1
vote
2answers
197 views

State Design Pattern

I've come across the following State Design Pattern which seems extremely logical and simple to implement: class CeilingFanPullChain { private State m_current_state; public ...
2
votes
1answer
107 views

Best way to deliver and deploy JEE application to client

I've worked for a few companies and even developed projects on my own - these projects were based on Java Enterprise Edition. Sometimes with Spring Framework involved, sometimes it was a pure JEE. ...
0
votes
1answer
77 views

Reference variable concept (Java)

I'm working my way (slowly, but surely) through a book: Introduction to Java Programming, 10th edition, Comprehensive, by J. Liang (ISBN10: 0133761312) It explains the idea of a reference ...
0
votes
1answer
100 views

Designing a program that runs scrtipts on multiple computers(JAVA)

So Ive been trying to design a program in java(because I might need to create an app that does the controlling part) with GUI that can run scripts on a few local computers. It should do the following: ...
1
vote
1answer
145 views

Design decision: class hierarchy or Java 8 Optional

I am really reconsidering my current class hierarchy for timeslots (in a schedule). I wanted to make them as flexible as possible so it would cover many possibilities of what we could understand as a ...
-1
votes
0answers
39 views

How should I use POJO in Scala?

I have created a Scala project that has Java dependencies at very low level (model, repository, etc.). Should I create implicit conversions to decouple it from POJO?
0
votes
1answer
278 views

How to solve this seating problem?

I was solving a seating problem whose solution seems trivial but I am not able to get it. The problem states in short that we have to seat n (even) students in n/2 rows where students are labelled ...
1
vote
5answers
179 views

How to optimize performance of sequential condition checks in Java?

I am writing a program that looks for a solution of a diophantine equation. The program is cycling for (int d = 0; d <= max; d++) { for (int c = 0; c < d; c++) { boolean ...
6
votes
3answers
581 views

Is it better to expose or hide dependency in OOP?

Let's say I have an object A, which is too big(having too many methods and variables). So, I break it down to smaller objects. After that, I have Object A, B, and C. Obviously, Object A is from Class ...
2
votes
3answers
1k views

Cache Json on disk with fast read back in java/android

summary: I need a way to cache a large JSONArray on disk, and be able to quickly read AND CONVERT it back to JSONArray at a later time. NOTE: my output MUST be a >>JASONarray<<, and not a ...
1
vote
1answer
119 views

Polymorphic constants in Java

I am designing some polymorphic code to perform mathematical operations. The idea is to abstract out the underlying representation of the data, as different use cases require different representations....
0
votes
1answer
128 views

Synchronisation with offline system

I'm designing a system from which I will synchronise business data from mobile device that have an embedded application that generates datas and send them back to the server. Each line synchronised ...
0
votes
1answer
955 views

Java: How to manage UDP client-server state

I am trying to write a Java application that works similar to MapReduce. There is a server and several workers. Workers may come and go as they please and the membership to the group has a soft-state. ...
7
votes
5answers
7k 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 ...
2
votes
4answers
130 views

Should CRUD actions be Java classes?

I am working on a simple project developing a telephone directory application. As such, it requires the implementation of the CRUD actions. Right now I have them as individual classes (e.g. "AddEntry")...
1
vote
2answers
61 views

How can I efficiently add/delete/get sorted data in Java?

I am writing a telephone directory program and need to store the entries in a CSV formatted file. However, I am having difficulty keeping the entries in order when adding. I was considering reading in ...
4
votes
2answers
142 views

Are API-changes expected in beta releases?

In an open source framework deprecated APIs were removed during the beta phase on the road to a new major version. Now users request to restore some deprecated APIs because it breaks compatibility. ...
-1
votes
2answers
175 views

Why is the syntax for a new object creation is little bit long in java? [duplicate]

After trying to write small programs with out reading much of the concepts in Java, the following syntax bugs me a little: Car volvo = new Car("Sweden"); class Car { String country; // ...
2
votes
2answers
127 views

Java: Composition of classes implementing same interface

Let's consider an example wherein I have to model the following: Class to schedule exams for a Student, lets call it StudentExamScheduler Class to schedule exam for a Class. Let's call it ...
0
votes
0answers
36 views

Profiling a java application making a lot of external http calls

I am having a java application which makes a lot of external http calls. To identify the hot methods I have used System.currentTimeMillis() in all methods and I observed that the methods who are ...
2
votes
1answer
482 views

Decoupled architecture in Android

I am building an app for Android that will have multiple data sources depending on who is using it. N-tier architecture with a repository pattern seems like the right way to go about this but I am ...
1
vote
4answers
289 views

why can't class directly take arguments instead of using a constructor?

I referred this page for understanding about constructors in Java: http://www.javatpoint.com/constructor So, I pretty much got it as in my own words: constructor has no return value and is used ...
3
votes
2answers
12k views

What is the difference between Enumeration and Iterator? [closed]

What are differences between Enumeration and Iterator This question is from early ages of interview , I have not seen this question on recent interviews but it was in 2012, now days questions like ...
-1
votes
1answer
157 views

Want Some Advice on Structuring My Text-Editing Program

I want to make a small command-line-run program that looks for a word or phrase in a target .txt. or .docx file, prints out a corresponding blurb about that phrase, and then replaces it with a ...
9
votes
1answer
313 views

Code Design: Delegation of arbitrary functions

On PPCG, we frequently have King of the Hill challenges, which pit different code bots against each other. We don't like limiting these challenges to a single language, so we do cross-platform ...
0
votes
0answers
17 views

Asynchronous SOAP web service using Axis2 ADB

I am trying to implement a asynchronous method to send SOAP messages to a client. I have a web service for which I use SOAP to communicate with the client. I am the server and I send SOAP xml messages ...
-1
votes
5answers
185 views

Finally block when no exceptions thrown

I'm doing some cleanup operations that could throw an exception, and I want to implement the logic of a finally block, but only if no exceptions are thrown: The initial implementation is this: ...
0
votes
1answer
117 views

How to setup multiple queries with slight differences

I'm writing a page that will show the user statistical data about some of our products. Basically the user can get results between a specific time frame, and also add on other data to lookup by. For ...
4
votes
4answers
2k 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 ...
1
vote
1answer
54 views

Coding guidlines for Controller and Dao?

My Controller code: ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ObjectReader objectReader = objectMapper.reader(...
5
votes
3answers
612 views

Is it a good practice to use suppress warnings in your code?

I use @SuppressWarnings("unchecked") and @SuppressWarnings("null") mostly above methods to let the code compile without any warnings but I have my doubts. Found this Stackoverflow question. Jon Skeet ...
2
votes
1answer
627 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 ...
2
votes
1answer
392 views

Logging RestTemplate's responses

I want to log responses using Spring's RestTemplate. At first I thought I should do it using a ClientHttpRequestInterceptor, but since every set of requests should be logged to a different file, I ...
1
vote
1answer
88 views

Better way to organize query methods in Android?

In my Android app I have a SQLiteHelper class that extends SQLIteOpenHelper, and takes care of things like table-creation and upgrades. SQLiteDatasource class that performs CRUD operations on the ...
2
votes
2answers
185 views

Why does the development team of IntelliJ IDEA‎ store its dependencies as jars (e.g. JUnit) inside their cvs?

The very popular IntelliJ IDEA‎ has currently saved a lot of dependencies as actual jar files in their git repository e.g.JUnit, which I don't understand. Build tools like Maven provide excellent ...
1
vote
2answers
101 views

Adding properties to exceptions

Is it wrong to add fields to exceptions? I have a problem that happens and I'm thinking of adding considerable information to an exception, but it sounds weird: an exception with getters. What you ...
0
votes
1answer
42 views

Removing constraints of Java array

Java arrays only allow subscripts to range between 0 and N-1 for an array of size N. The class below aims to remove that constraint by allowing the class user to specify the valid subscripts ...
0
votes
2answers
421 views

Automatic Type Promotion in JAVA

I have started studying JAVA . In there, byte ch=50; ch*=2; works fine. But byte ch=50; ch=ch*2; does not. error:possible loss of precision required:byte found:int Why this do not happen ...
5
votes
4answers
308 views

Is “use ”abc“.equals(myString) instead of myString.equals(”abc“) to avoid null pointer exception” already problematic in terms of business logic?

I heard numerous times that when comparing Strings in Java, to avoid null pointer exception, we should use "abc".equals(myString) instead of myString.equals("abc"), but my question is, is this idea ...
0
votes
0answers
24 views

Providing an API for Cancel(QueryID) i.e. Cancelling a long running query through JDBC in RESTful service

We went through few blogs on internet, which suggested to use Statement.close() method. Our scenario : We have developed RESTful service. We execute an SQL query through JDBC framework behind an API ...