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

-4
votes
0answers
25 views

What is stored on the Heap? [duplicate]

When it is said objects are stored on the Heap, which objects does this refer to? In the following example a is stored on the Stack. MyType obj a= new MyType(); a.meth(); So what is stored on the ...
-2
votes
1answer
30 views

ClickHandler for button = strategy pattern? [on hold]

If you provide a implementation of a ClickHandler interface to a button (defining some behaviour), is this the strategy design pattern?
1
vote
1answer
66 views

How to concurrently write data in Java without locking?

How to implement a multi-threaded program in which each thread needs to write/output some data (in any order of course) but without the locking overhead that is involved with files or a particular ...
-1
votes
0answers
18 views

Java program exit function not working [migrated]

i'm a newbie to java so i decided to create a simple program that prints out even numbers. I tried to make it exit a while loop if you answered no to the question but it just keeps on going. Here's ...
3
votes
3answers
126 views

How many threads should I use in my NIO server?

I've built a Java NIO TCP server, it currently uses four threads. One ServerRunnable thread that uses a selector and three worker threads. I've been looking around for some information about this, ...
3
votes
3answers
126 views

How to open a desktop application through browser without a Java applet?

We run a cloud-based medical software, and a very important part of the program is bridging to an imaging software straight from our website, passing information through command line arguments. We ...
1
vote
3answers
128 views

Using System.err.println() for debugging in Java

System.err The "standard" error output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output ...
23
votes
7answers
3k views

Should I validate a method call's return value even if I know that the method can't return bad input?

I'm wondering if I should defend against a method call's return value by validating that they meet my expectations even if I know that the method I'm calling will meet such expectations. GIVEN User ...
-2
votes
1answer
48 views

Reading from html page that needs cookies passed and form data [on hold]

I am writing a program in java in order to practice tough coding problems and learn more. Program description The program reads first names from a text file one by one, then enters them into facebook ...
1
vote
2answers
81 views

Should method names getX and setX only be used for fields and have no other effects? [duplicate]

Should I avoid using getX() and setX() as names for methods that aren't "traditional" getters or setters? (Let's define traditional as it only gets/sets the field and has no other effects.) I guess ...
0
votes
2answers
82 views

Check if a variable is equal to any of several values

I'm trying to check if an integer is equal to any of several values and don't want to do this: int d = 0; if(d == 3 || d == 8 || d == 1) { System.out.println("d is one of the special numbers!"); ...
25
votes
10answers
3k views

Is it okay to have objects that cast themselves, even if it pollutes the API of their subclasses?

I have a base class, Base. It has two subclasses, Sub1 and Sub2. Each subclass has some additional methods. For example, Sub1 has Sandwich makeASandwich(Ingredients... ingredients), and Sub2 has ...
3
votes
1answer
353 views

Scheduling a few CPU-intensive tasks

I need to schedule a small number of CPU-intensive tasks to run every so often, reading from shared data and writing to dedicated buffers. I don't necessarily want to roll my own scheduling, but am ...
7
votes
2answers
247 views

Retry design for high volume

I have a Java system using ActiveMQ for messaging. And the system processes about 400 to 600 transactions a second and we have no issue when everything is running smoothly. The system also got to send ...
0
votes
1answer
350 views

MVC: How to Implement Linked Views?

I'm developing a java application to visualize time series. I need (at least) three linked views, meaning that interaction with one of them updates the others. The views are: A list represents the ...
-3
votes
0answers
125 views

How can I deal with apathy in the workplace? [on hold]

I've recently been sent a meeting request to put forward a proposal to upgrade our Java version to 8. I'm quite enthusiastic about the features implemented in version 8 so I thought it would be a good ...
-4
votes
0answers
20 views

GCC Ada command line [on hold]

[Windows 8.1, 64-bit, using the most recent MinGW] So, basically, I need to compile a .adb Ada file and get it's output .o file. Buut, I have to do this programatically - more specifically, in Java. ...
-3
votes
0answers
15 views

Spring batch design (Data enrichment) [on hold]

I have a working spring batch program that reads from a DB , the writes into a file. However I need to add labels to data so for example I need it to print student:John|LastName:Smith .. Etc my ...
-4
votes
0answers
37 views

Why do we still have problems with foreign characters? [closed]

We want åäöÅÄÖ to work (for a custom cryptography) with Java. It seems that there is a problem whether åäöÅÄÖ are before Aa or after Zz. Which is it and which should it be? Am I mistaken that this has ...
0
votes
0answers
71 views

How to build full modular app [on hold]

I have full monolite app on java/scala and all modules work trough "Interfaces". For DI/IOC I use Guice. As example of structure:   How to organize structure of build for build different ...
1
vote
2answers
258 views

A 'task' system which has an ending, to get ready for next task

I want to make a system, so that there are certain tasks. For example, let's talk about a game. I want to make it so there are 100+ tasks doing different things, but when the player's magic level is ...
-1
votes
0answers
48 views

BabysittingJob wont give me the proper output? [duplicate]

I am supposed to create an object with different fields for a babysitting job. and display all of the fields. This is what I have: public class BabysittingJob { private int jobNum; private int ...
3
votes
4answers
633 views

Robot in a grid

This was recently asked to someone I know. A robot has to move in a grid which is in the form of a matrix. It can go to A(i,j)--> A(i+j,j) (Down) A(i,j)--> A(i,i+j) (Right) ...
0
votes
2answers
239 views

How to manage data flow between UI components?

I have been trying to use classes that implement ActionListener to respond to user input. I'm consistently noticing that for an action listener to communicate the event to other objects, it has to ...
15
votes
6answers
2k views

Why is Javascript used in MongoDB and CouchDB instead of other languages such as Java, C++?

I asked this question on SO but was suggested to try here. So here it goes: My understanding of Javascript so far has been that it is a client-side language that capture events and makes a web-page ...
-1
votes
2answers
388 views

Initialize in Field, Constructor, or Argument

If I know what a field will be initialized to, should I initialize it in the field, constructor, or receive it as a parameter? I am asking about best practices. All three options effectively provide ...
18
votes
4answers
2k views

How much refactoring is acceptable? [duplicate]

I am currently in a project where one of my developer colleagues constantly refactors stuff on every ticket he's doing. We are using agile methodologies. I know that refactoring is a good thing to do ...
21
votes
7answers
16k views

What is the difference between “data hiding” and “encapsulation”?

I'm reading "Java concurrency in practice" and there is said: "Fortunately, the same object-oriented techniques that help you write well-organized, maintainable classes - such as encapsulation and ...
-5
votes
0answers
42 views

Bitwise operation and mobile computing. Where does it help? [duplicate]

This is another Theoretical question that has to do with engineering as well. Please be patience to my question. Maybe it is unclear because my view on the subject is unclear and that's why I am ...
0
votes
0answers
5 views

How to apply custom drop-down properties for my custom JComponent [migrated]

I have created a custom swing JComponent and have applied it to my NetBeans v8.0.2 palett. The component works well and can be dragged and dropped into a JFrame (UI form) without any issues. My ...
-2
votes
0answers
28 views

More efficient way to write this code [migrated]

I'm learning java and was making a program to go along with the board game clue. I type the name of who didn't do it and it takes them off the list. I want to evolve this program to be able to do ...
-2
votes
0answers
33 views

Best framework in java for responsive web application with simples 2/3 form and search page? [closed]

I want to architect and develop simple web based application with simple 2/3 forms and search pages and user administration, backend is oracle RDBMS. Can I know best responsive java framework ...
58
votes
5answers
6k views

What exactly makes the Haskell type system so revered (vs say, Java)?

I'm starting to learn Haskell. I'm very new it and am just reading through a couple of the online books to get my head around its basic constructs. One of the 'memes' that people familiar with it ...
1
vote
1answer
289 views

DataMapper for a MMO game plugin to send packets

I am working on an plugin for some game-server. The information about the plugin is not really necessary. Few points you might find helpful to answer to this question: The server The server is ...
2
votes
2answers
192 views

Why are the types in Java considered less 'strong' than haskell?

I asked this question a while ago - the answers were really helpful, and as I read them and the questions that were linked - I also saw this, and the first answer I think really addresses what I ...
1
vote
1answer
88 views

Non-fixed-size Fenwick Tree implementation

I'm planning to implement a non-fixed-size Fenwick tree. That is, a Fenwick tree that allows interleaving range queries with adding/removing elements. All implementations and samples I've seen so far ...
12
votes
6answers
2k views

Homework for strong C++ developers learning Java [closed]

I'm tasked with teaching an accelerated university special topics course in Java for programmers with many years of experience in C/C++. What sort of medium-length (1-2 hours max) assignments would ...
-1
votes
0answers
21 views

sending data from device to remote server [migrated]

My application is passing two value from device to remote server but it work in when i tested in bluestack when I install in real device it show a message like "Unfortunately app has been stooped" so ...
0
votes
0answers
18 views

accelerometer code in class [migrated]

I'm writing an app that show accelerometer readings, I was able yesterday to write all the accelerometer code in the main activity and it works fine on emulator and my device. But today I was trying ...
-2
votes
0answers
22 views

generating best fit from 3d datapoints [closed]

given N datapoints of point(x,y,z) how should I go about generating the best fit line for this dataset? Accuracy is more important than speed as the collection of best fit lines will be precomputed ...
-8
votes
0answers
36 views

Writing an application [closed]

I have done a lot of experimenting with all sorts of programming languages and am wanting to create a desktop application that can send and receive messages as well as notifications, etc from ...
0
votes
0answers
39 views

Testing if any two given objects are equal [closed]

As described in the title I want to write a code that can compare any given objects and check if they are equal. Here's a sample code: public static boolean equals(Object o1, Object o2) { if ...
2
votes
2answers
784 views

About insertion sort and especially why it's said that copy is much faster than swap?

From Lafore's "Data Structures and Algorithms in Java": (about insertion sort (which uses copy + shift instead of swap (used in bubble and selection sort))) However, a copy isn’t as time-consuming ...
0
votes
2answers
487 views

Is factory pattern a right pattern for the situation described here?

Is factory pattern a right pattern when we want to consolidate the related objects? Problem - In the Set-top box, I have a user-io, basically the interface to control the settop box - The user-io can ...
4
votes
3answers
445 views

How to conduct a 3 days training on current techniques like TDD and CI

I am tasked to conduct a training for an upcoming team of 20 Java developers for a new project. The project owner wants us to use state of the art development techniques like TDD and CI. The ...
4
votes
3answers
207 views

Automatic builders/chain setters for Java?

Consider that code: FancyClass c = new FancyClass(); s.setParameter(value); s.setParameter2(value2); //a lot of parameters It is really naive, so we can use a builder pattern: FancyClass c = new ...
28
votes
10answers
3k 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 ...
-3
votes
0answers
25 views

How to use Multiple class in javascript function for testmonial? [closed]

I Have Two Div I want Use this Class For Testmonial Show Please Tellme How I use 2 class in one Function.
-4
votes
0answers
28 views

Arrays List and loops [closed]

I'm not really sure how I could arrange these two in code to combine them together. I start off with five groups of some amount of cards which I believe that I can use an arrays list. But then I have ...
1
vote
0answers
56 views

Simple REST API calls using Spring? [migrated]

Okay I'm having a simple REST API that is now running. I also got a mobile app (Android) that would be ready for some network communication. But here is the thing: I now got a fancy API created with ...