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

7
votes
2answers
673 views

Is it poor practice to call methods through multiple objects? [duplicate]

I have code that looks like this: tr.t.findIndexSmoothed(arg0.getX(), arg0.getY()); "tr" and "t" are objects. Is it bad practice to reach all the way down the object hierarchy to call methods? The ...
9
votes
3answers
4k views

Java Heap Allocation Faster than C++

I already posted this question on SO and it did ok. It was unfortunately closed though(only needs one vote to reopen) but someone suggested I post it on here as it is a better fit so the following is ...
2
votes
1answer
568 views

Can you help me understand this design pattern made by Java expert?

I inherited the project from a very experienced Java developer. The project is Android app and the guy who coded is is very experienced in coding regular Java apps. He introduced some file structures ...
1
vote
1answer
251 views

MyListActivity, MyCursorAdapter, MyViewHolder — nested classes or not?

I am using several activities based on the ListActivity. All of them display information from different SQLite queries, and all of them use the ViewHolder optimization. The cursor adapter have to be ...
2
votes
1answer
206 views

How to deal with runtime changes to tenant-location in a clustered, multitenant web application with app-managed datasources?

I have a Java web application that supports multi-tenancy to keep customer data separate. Connection pools to each customer database are created at runtime. The details of each customer shard ...
-1
votes
1answer
661 views

Options for implementing aggregate message processing [closed]

I am developing a web service in java that requires to do an asynchronous call to a 3rd party app by aggregating about 100 requests or for a minute (whichever happens earlier). Is there any open ...
0
votes
2answers
161 views

Utilizing a Java Concurrent Utility from a Web App

I have the following lines of code in my application: return "Service is alive since: " + TimeUnit.MILLISECONDS.toMinutes(mxBean.getUptime()) + " minutes"; It uses the following package: import ...
10
votes
2answers
4k views

Naming conventions for Java classes that have a static main method?

After reading gnat's answer to Why a static main method in Java and C#, rather than a constructor? I take his answer to mean that the purpose of a Java class with a static main method is to define a ...
5
votes
4answers
2k views

What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?

I have been going through interview questions and I saw one which made me stop and think for a while. It starts with a quote and asks about your interpretation and whether you agree or not. "For ...
23
votes
4answers
2k views

Why Java doesn't make use of encapsulation with some classes?

My question is related with System.in and System.out classes (there might be others like those in the Standard library). Why is that? Isn't that a bad practice in OOP? Shouldn't it be used like: ...
0
votes
1answer
441 views

Apple Dispatch Queue vs Threads

I've heard a lot about apple's famous dispatch queues and the GCD but today was the first time I decided to understand exactly what is going on, so I started reading Concurrency Programming Guide and ...
3
votes
1answer
184 views

Why are some minor update versions of Java skipped?

Up until around January 2013, the minor updates of major Java versions were always consecutive: 6u30, 6u31, 6u32, 6u33 and so on. The same is true for Java 7 updates. But, starting around January or ...
3
votes
1answer
507 views

How to see what parts of your java code are run most often?

I would like to be able to see what code in thousands of lines of source code is run most often and takes the longest. The purpose of this would be for optimization. Being able to see what parts of ...
1
vote
1answer
202 views

Compiler design decision for dynamic method invocation

I asked about Compiler interpretation of overriding vs overloading on StackOverflow, and got good answers, but this led me to another question that I'm not sure is appropriate for SO, but I think is ...
1
vote
1answer
198 views

Law of Demeter issues with complex class design

I've posted questions pertaining to this issue before, but they've all tackled different aspects of the problem (Just so you know that I'm not reposting the same question to get more answers). So, in ...
0
votes
1answer
203 views

Do we need to use JCA while connecting to db from inside EJB

While writing an EJB (deployed on WAS) that connects to a db, i have never needed to use JCA. But apparently JCA is the standard for connection to thrid party EIS (which includes database). So does ...
4
votes
2answers
664 views

Publish/subscribe, observer pattern implementation question

I'm developing desktop application in java/swing. I have a component that is registered as a subscriber to many panels and gets messages (my custom event) from them. That component is something like ...
0
votes
1answer
408 views

What design do I follow to convert my classic ASP pages to a Java Enterprise Web Application? [closed]

There are so many Java technologies that it is difficult for me to know where to start. I understand JSP and Servlets. I know what http servers to use. Real basic stuff. What I don't understand is ...
0
votes
1answer
367 views

Can we call final field as object's constant?

We call static final fields as constant, rather I should say Class constant. So can we call just final fields as Object's constant? Is it right to say this? Edited :: Consider the following code : ...
3
votes
3answers
663 views

Parallel Class/Interface Hierarchy with the Facade Design Pattern?

About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line). Naturally, it delegates responsibilities to the ...
1
vote
2answers
978 views

Data Aggregation of CSV files java

I have k csv files (5 csv files for example), each file has m fields which produce a key and n values. I need to produce a single csv file with aggregated data. I'm looking for the most efficient ...
1
vote
1answer
239 views

Are Protected Auto-Cast Methods Ok?

I often have superclasses that contain a more abstracted form of a class as a member variable than my subclasses need. I find my code littered ((ClassName)variableName).methodName(). Is the best way ...
3
votes
2answers
401 views

Can classes violate Single Responsibility if they delegate internal tasks?

I have two classes Output and Timeline, neither of which violate SR, but the two of them are linked together. So what I'd like to do is have a class called Elco (there's a reason behind the name) that ...
4
votes
1answer
469 views

Should I use JavaFx properties? [closed]

I'm usually very careful to keep my Model, View, and Controller code separate. The thing is JavaFx properties are so convenient to bind them all together. The issue is that it makes my entire code ...
9
votes
7answers
3k views

Java - Why do we call an array a “vector”?

I am reading a book on Java Programming, and want to confirm I understand the definition of the word "vector". Wikipedia says vector is "A one-dimensional array", source ...
-3
votes
3answers
774 views

Programming to interface in Java [duplicate]

What is the real use of interfaces in Java? What is meant by programming to interfaces? I heard these things several times but I don't know what it is and why it is used.
2
votes
2answers
8k views

Do pointers really exist in Java? [duplicate]

I read quite a few resources on the internet and now I am quite confused about the existence of pointers in Java. Some claim that there are pointers and some claim that there is no such concept. So ...
1
vote
1answer
427 views

Internal exposure of implementation details on inheritance

I'm reading the "Effective Java" book which suggests to favor composition over inheritance. The example it gives shows something like this: public class InstrumentedHashSet<E> extends ...
2
votes
4answers
824 views

Explanation of the definition of interface inheritance as described in GoF book

I am reading the first chapter of the Gof book. Section 1.6 discusses about class vs interface inheritance: Class versus Interface Inheritance It's important to understand the difference between ...
2
votes
1answer
634 views

Does “cc”, “vv”, “^^” have a special meaning in code? [closed]

Occasionally in code at GitHub I see tags "cc", "vv" and "^^". Do these have any special meaning? Example: // cc MaxTemperatureMapper Mapper for maximum temperature example // vv ...
2
votes
4answers
157 views

Subclassing to change default settings?

I have a class called Timeline. I want to allow several defaults in my code, such as a Timeline with a Start event (The details are not needed. All that matters is that I have a class, and I want to ...
2
votes
4answers
5k views

Java class to enforce an implementation of super classes' public methods

I have the following : public Class A { public void methodA() { .... } public void methodB() { .... } } I don't have control over Class A. I would like to create ...
10
votes
3answers
960 views

Why do different java collections have different default capacity?

Looking at different collection constructors the question comes to mind. Why does ArrayList() construct an empty list with an initial capacity of ten and ArrayDeque() constructs an empty array deque ...
3
votes
2answers
1k views

Collection interfaces in C#, coming from Java

In Java, I'm used to declaring collections using the most-abstract interface possible and then constructing them using the concrete implementation that makes sense at the time. It usually looks ...
2
votes
1answer
3k views

How to make a method synchronized across all instances of an object

Today I was asked this interview question and could not answer. : If you have two instances of a Person Object and each of them have a setAddres method that is synchronized. Now if it was only one ...
0
votes
1answer
379 views

Do I have to release source code because I'm using JavaFX?

I'm using JavaFX for gui of my app. Its license is GPL+Linking Exception. GPL requires me to release my source code. But what's the linking exception?? (I'm just using it as a library. Not modifying ...
-4
votes
4answers
482 views

Why must a constructor's call to the superconstructor be the first call?

It is an error if you do anything in a constructor before calling the superconstructor. I remember that I had problems because of that. Yet, I do not see how this saves us from errors. It could save ...
3
votes
6answers
2k views

Why does Java compiler decide whether you can call a method based on the “reference” type and not on actual “object” type?

I was just wondering why does Java compiler decide whether you can call a method based on the "reference" type and not on actual "object" type? To explain I would like to quote an example: class A { ...
11
votes
3answers
2k views

How to create better OO code in a relational database driven application where the database is poorly designed

I am writing a Java web application that consists mainly of a bunch of similar pages in which every page has several tables and a filter that applies to those tables. The data on these tables comes ...
0
votes
1answer
123 views

Do JAX WS implementation classes come as part of the Java 5/6 package or only as part of an application server libraries?

Do JAX WS implementation classes come as part of the Java5 package, as part of the Java6 package or only as part of an application server libraries like WAS? I read that it comes as part of Java EE? ...
17
votes
7answers
2k views

Does modular programming affect computation time?

Everyone says that I should make my code modular, but isn't it less efficient if I use more method calls rather than fewer, but larger, methods? What is the difference in Java, C, or C++ for that ...
1
vote
2answers
218 views

Determining the aggregates in this domain

I'm working on an ordering system where we receive tab delimited files that look like this (I removed most of the columns for clarity): OrderId OrderLineId BuyerName BuyerAdress ...
0
votes
1answer
187 views

Should an algorithm handle invalid inputs and can it have hard-coded paths for certain input data? [duplicate]

I have certain preconditions on input data and I need to design an algorithm for that data. Should I also handle invalid preconditions? Also is it normal that my algorithm will work only for a ...
15
votes
4answers
669 views

how to determine minimum requirements of a software [duplicate]

Some software (commonly the commercial ones) producers provide minimum requirements, some examples: Skype, Diablo III, Ubuntu-Server and OpenOffice. I wonder how those minimum requirements are ...
-3
votes
2answers
2k views

Java: The best way to learn it when MOOCs and books are not enough? [closed]

This topic was taken from Stack Overflow, but it was put on-hold due to Opinion-based question. So I moved it to here. I've had some great troubles with my homework exercises and I've used ...
1
vote
1answer
962 views

I18n strategy for java web apps

Internationalized applications usually display links in header for translating in different languages, e.g.: Spanish | English | Italian. These links usually translate current page in the selected ...
0
votes
1answer
211 views

BlazeDS: Server DTO method naming convention

I have the following field in Flex: [Bindable] public var zIndex:uint; And I was trying to create the methods to process the calls in Java and I ran into a problem. 1. public int getZIndex(); // ...
1
vote
3answers
425 views

What does “(say)” mean in this Java method in Hadoop The Definitive Guide?

What does "(say)" mean in this Java method? Since Mapper and Reducer are separate classes, the type parameters have different scopes, and the actual type argument of KEYIN (say) in the Mapper may ...
4
votes
1answer
2k views

Why does Android's Bundle API accept ArrayLists rather than Lists

I'm new to Android and while going through a tutorial on saving Activity state to a Bundle, I noticed that instead of accepting the more generic List interface, Bundle's put methods are expecting ...
4
votes
4answers
430 views

Law of Demeter causing subclassing indecision and conflict with Single Responsibility

This is my situation: I have a class called CueList, which is basically a wrapper around ArrayList. I have another class called TimeTicker that alerts all the Tickable (interface) in its list that a ...