Tagged Questions

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

2
votes
1answer
46 views

Defensive copy in in the client class or in the service class?

I have one service method that receive parameters as a Map. I will need to add new attributes to this map inside the service. If I pass the original Map object to the parameter instead of a copy, the ...
-4
votes
0answers
36 views

Glued code performance: How does this approach change your code performance? [on hold]

I recently stumbled over this idea when I was optimizing my Python code. How much of a difference does it make if you produce code in a language like Java versus a program architecture written in ...
0
votes
0answers
6 views

How would I compare field values of two Java objects of the same but unknown type recursively? [migrated]

We are parsing XML configuration files with JAXB into Java objects. The XML files are versioned and after loading version 1.0 and 2.0 into objects we would like to compare the two objects of the same ...
1
vote
3answers
358 views

Should one value simpler code over performance when returning multiple values?

I'm too often facing situations where I need to get several types of information from a method. I usually think long and hard to circumvent these situations but I'm thinking it's pointless work that ...
0
votes
0answers
11 views

webdav in jsr268 portal application

We have a web application that we have made portal compatible(JSR 268) using spring. One part that has not been ported across is a WebDav servlet. Is it possible to have a portlet handle WebDav? or ...
-4
votes
0answers
23 views

How can I make a HashMap that can System.out.println(“Category” + “descriptor” + value) readed from text files [on hold]

i have a program that outputs some text into a test.txt file. in the txt file the text shows like this : [Computers] Keyboard=10 Mouse=5 [Cars] Lamborghini=6 BMW=3 I want to create a program that ...
-5
votes
0answers
53 views

To built the GUI of battleship [on hold]

Currently I am working on a battleship game for multiple clients. The code is in JAVA which is back-end. now I want to make GUI of game i.e. front-end. I am confused which language will be good for ...
2
votes
0answers
91 views

Java Memory Management - java web start “Error: could not create the java virtual machine” [migrated]

I have defined a jnlp file with initial-heap-size="512m" max-heap-size="1024m" on a machine that has 16Gb with 12Gb available. The JVM running is a 32-bit JVM because of native libraries. I ...
0
votes
1answer
66 views

Algorithm to create custom ConcurrentHashMap?

I tried to look into concurrent HashMap source code to look in to how it is implemented. To me it looked very difficult to understand((In no way i am saying its not required :))). I thought if i need ...
-4
votes
1answer
83 views

Left a job and now looking for a switch in my career [on hold]

I had a complicated start in my career, I worked in xml, xslt only but these languages are not widely used everywhere. I changed my job after 2.2 years and got another company, but due to some issues ...
0
votes
0answers
64 views

Strange result from perlin noise generator [migrated]

I have been experimenting with perlin noie generation for a game i want to program but i have run into some strange results. When i let my code run and draw the result in grayscale i get the following ...
4
votes
0answers
118 views

How to get a one-way hash function that is collision safe for about 1 million unique inputs? [duplicate]

Forgive me if this is a noob question - My CS education is a somewhat incomplete Basically, I need a way to hash an input, so that someone seeing the output doesn't see the original input value. ...
0
votes
0answers
5 views

Logic Error: Optimally Deleting Zeros from a random [Mod(2) + 1] Matrix [migrated]

Is my error-handling tag misplaced? I'm still very new to java and programming, and likely made this mistake by programming too much too fast. However, now I have a nasty logic error and could use ...
-4
votes
0answers
70 views

Can array have an “if” statements? [closed]

I tried to make an "if" statements in an array and i don't know how.Is it possible that array can handle an if statements?Please send me your answer!
-5
votes
0answers
39 views

Java display problem (android project school) [on hold]

My first app is a register app where user can get registered into a MySQL database and can also get connected. One connected my app display a welcome page. My second app is a GPS tracker, that have ...
-1
votes
1answer
64 views

Shall one return a manipulated List for better readability? [on hold]

The code below shows that lists (in Java) which will be manipulated in a function will be manipulated in the main code block, too. But e.g. Strings won't. One will need to return the manipulated ...
0
votes
1answer
51 views

Debugging xml and annotations

By now, most web containers have an annotation variant of their xml configurations for Java EE. I'm guessing this is because it's better to keep things in Java where they can be managed, coded with ...
-1
votes
0answers
41 views

Sum of Digits in Java using only beginner stuff [closed]

I am trying to find the sum of digits in a factorial. For instance, the output I get is a=531; what I want to find is the result 5+3+1=9. However, I can only use for loop, I am not allowed to use ...
-2
votes
0answers
55 views

How to control a Java program interactively via buttons in a GUI? [closed]

I have an application to which I need to provide a GUI that exhibits the current state of a handful of items (custom objects) that are pretty much the core of such application. However, since the ...
0
votes
0answers
4 views

Programming in Debug context in Eclipse IDE [migrated]

Is there a way to program (Java), I mean, write some piece of code anywhere in IDE, to evaluate something in the current debug context when the program execution is waiting on some debug point in an ...
0
votes
1answer
175 views

How to spawn multiple “monsters” from a single class [closed]

How to spawn multiple "monsters" from a single class? Can store it in an array, ok, but later on, how can I paint it? Because if I do: enemy = new Enemy(); enemy2 = new Enemy(); I create two ...
17
votes
7answers
2k views

What can one do to improve readability of math-oriented code in C#, Java, and similar? [closed]

As both a C programmer and a C# programmer, one of the things I don't like about C# is how verbose math functions are. Every time you would have to use a Sin, cosine, or power function for example, ...
0
votes
1answer
137 views

Best practices for developing desktop application for Windows and Linux? [closed]

I have to provide a small application that should be run on both Windows and Linux \UNIX. A desktop application. It should provide one screen and a few buttons on it. It should run some commands in ...
1
vote
3answers
260 views
+200

Pluggable UI Components in Java Web Applications

I will try to explain my question with an example. Let us say that we are writing a hotel reservation system which is web based using Java. We will have different payment methods, say Paypal, Master ...
-2
votes
0answers
50 views

Potholes in a multiplayer snake where players can use their own algorithms

I'm developing a snake-like multiplayer where players can use their own algorithms to determine the next move of their snake. A little background: My game searches a folder for any compatible .jar ...
-4
votes
0answers
61 views

Guidelines for developing SAAS applications in java [closed]

Are there any guidelines which assist in building SAAS applications ? Just to gain experience, I want to build a SAAS application. Say a library system. Other than knowing that the basic approach ...
1
vote
3answers
191 views

Implements > extends, but what about variables?

It's preferable to write programs that depend on interfaces rather than on superclasses, but what when you want a class to have certain variables? Sometimes you want a class to implement a certain ...
-3
votes
0answers
35 views

OCPJP questions with answers [closed]

Can you guys give me some links which have OCJPJ questions with answers ? I am new to OCPJP and I iike to enhance my knowledge. I Hope I can learn more through doing questions and answering them. I ...
0
votes
2answers
120 views

Should I have an object as attribute or primitive id?

I am wondering which principle should I use. Here is my situation. I have a class named TravelOffer. This class looks like this: public class TravelOffer { private final long id; private ...
1
vote
1answer
80 views

Best approach to a defined datastructure

I have a plain text file with some data that I can't change, so I have to create a datastructure to use in reading the file and with that datastructure do some thousands of interactions. The file ...
-1
votes
1answer
50 views

Inheritance vs Association in this example

I'm designing a very simple fixed asset management system in Java. The system consists of the following entities as displayed in the following ER diagram. My problem is the design approach to be ...
0
votes
2answers
235 views

What type of structure is this in java?

I was reading the following code listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) ...
-6
votes
0answers
50 views

How to make a 2D to 3D converter in Java? [closed]

I know that there is software out there that creates 3D models/scenes out of a series of images. I am very interessted in how that works and so I would like to do this on my own in java. But how does ...
2
votes
1answer
133 views

CopyOnWriteArrayList: Why do we have to make a full copy of source data?

I have a lot of confusion about Java's CopyOnWriteArrayist. I know, when we have a modification on it like update, insert of set, it will lock the whole list, copy out a total copy of the source list, ...
1
vote
4answers
376 views

Should all programmers know how to solve algorithms, etc [closed]

I'm 15 and have been programming for about 3-4 years. I mostly program in Java as it was my first language. I would like to be a programmer when I'm older, but I'm not sure about the differences. ...
-3
votes
1answer
46 views

Java Licenses, GPL, GNU Questions

I would like to ask a few questions about software licenses, with regards to a (Java) program I am making. I am very very new to licenses, so please bear with me. 1. If I produce a Java program using ...
0
votes
0answers
28 views

Java API initialization step

I am developing an Android Library which involves both Network and Bluetooth communication. In order to start using the library it must be configured. In other words a request to the backend must be ...
0
votes
0answers
33 views

What is the best way to sort strings with multiple words in each line and is separated by newline in Java? [migrated]

I have list of anime that i have watch uptill now and i want to sort them in alphabetical order. Below is the small example of how the list is and there are over 200 lines. I have stored all of them ...
0
votes
1answer
109 views

Separating UI from logic

I'm trying to develop a little game and for this I'd like to separate the UI from the game logic. So I'm thinking of using an "Animator" class that will be responsible for rendering the objects, but ...
0
votes
0answers
46 views

How do I access the data in Java objects returned by User.getAddresses() and User.getPhones()? [migrated]

In com.google.api.services.admin.directory.model.User, many methods, such as getAddresses() and getPhones(), return a Java object that I can’t figure out what to do with. Using toString(), I can ...
1
vote
2answers
137 views

Ensure scheduled event only runs once a day?

In a hobby project of mine, a "smart home" for controlling lights, I'm planning to create a feature which turns off all lights at a given time of day. There are also several other features which runs ...
2
votes
1answer
72 views

Is there a limitation when using the Bloch's Builder Pattern with mandatory fields?

Background I have a class TextDrawable which draws text on top of a shape. There are a number of properties that can be set while creating a TextDrawable object. Mandatory Properties: Text Shape ...
1
vote
1answer
92 views

Best OOP pattern to use for creating a commandline SQL API for a proprietary json based company datastore

We need to create a SQL commandline tool for querying a proprietary json based datastore. I'll be using java. Any suggestions on the primary OOP design pattern I should use for building this API? ...
0
votes
1answer
81 views

when would you wrap a service object with an interface? [duplicate]

I'm new to UT and some of the best practices and anti-patterns when writing testable code, made me think. I used to wrap any service object with interface. but I see many mocking frameworks can ...
0
votes
0answers
53 views

when would you write static method as it avoid a “seam” for testing [duplicate]

when would you write static method. I used to write it in utils classes where all the methods are static and work state-lessly on arguments only. But now I know it blocks from creating a seam in ...
0
votes
2answers
108 views

Java Multithreading and CPU cores [closed]

I have a simple question this time. If I write an java application with 4 Threads ( each thread does different work ), what will be the difference between single-core, dual core and quad core cpu ( ...
3
votes
3answers
299 views

Immutable objects [closed]

Looking at questions such as these If immutable objects are good, why do people keep creating mutable objects? What are the drawbacks of immutable types? At what point do immutable classes become a ...
0
votes
0answers
3 views

What is the reason behind this Eclipse behavior due to changing an Environment Variable? [migrated]

I have two versions of Eclipse that I use (Indigo for C++ and Helios for Java). I've used both for years without problems. Last week I needed to view Java Bytecode, so in my Environment Variables I ...
0
votes
1answer
140 views

Ensure that a method of a class is called after every method call of the same class, how? [duplicate]

I have twenty small methods (m1, m2, m3, etc..) in a class quite different between each other, and after every method i would like to do some common actions, like increasing some counters and in the ...
2
votes
2answers
141 views

Design - Parser.hasInfo(MyClass) vs MyClass.hasInfo()

I'm working on a document processing system. I feel confident with a Document class which represents each document being processed. The issue: Each Document can have a CoverSheet, and if it does, ...