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.
1
vote
1answer
30 views
Language support for (syntactic) delegation in Java
Composition over inheritance is an old trend or even accepted state of the art in object oriented programming. It would be even easier to use in Java, if there were language support for delegation. ...
0
votes
0answers
11 views
Transparency of Pixel under mouse - Java JFrame [migrated]
I'm new to java and decided to make a program that : sets a point in the window when you left click. And then another point when you click again. And so on... Then it joins all the points up with ...
-1
votes
0answers
48 views
How can 2 or more threads use same run method but work on different threads? [on hold]
Platform- java applets with multithreading OS- Ubuntu
There are 2 arrays x and y with 100 elements each. These arrays store the coordinates of an snake. The run method is used to manipulate the ...
6
votes
7answers
1k views
Why is instance creation the way it is?
I've learned C# over the course of the past six months or so and am now delving into Java. My question is about instance creation (in either language, really) and it's more of: I wonder why they did ...
-4
votes
0answers
30 views
Language for Web development on Embedded Systems [on hold]
I am planning to host a webserver on an embedded board like raspberry pi, radxa rock.
It should also contain a database like MySql.
My concern is that performance wise as well as development ...
-2
votes
0answers
26 views
How can the Scanner read input from a file and ignore comment lines? [on hold]
The purpose of the program I've written is that it's supposed to load the input file "opcode.txt". My program works correctly when deleting the comment lines of the input file, but the professor ...
-1
votes
0answers
25 views
Intro to Software Engineering Project [on hold]
So we're working on making some sort of large software project that we need to finish by the end of a full semester at school, and we have no idea what to make. The teacher is real open to pretty much ...
-3
votes
0answers
24 views
What sort of training should I do to make better use of YourKit? [on hold]
My company uses YourKit as a load testing tool. My team currently has a web application that has slowed down slightly since the last update. It's not so bad that any users are complaining but it's ...
1
vote
1answer
59 views
Open closed principle vs abstraction leaking (Java enums)
In Java, an enum is not a plain replacement for a number (like in C/C++), but a family of objects which can have properties. For instance
public enum Order {
NAME("Ordering by name"),
...
9
votes
4answers
384 views
“Use map instead of class to represent data” -Rich Hickey
In this video by Rich Hickey, the Clojure creator, he advises to use map to represent data instead of using a class to represent it, as done in Java. I don't understand how it can be better, since how ...
-4
votes
1answer
54 views
How to stop HTML scraping when we see a specific tag [on hold]
I am scraping an HTML page using jsoup and I want to stop scraping HTML when I see this HTML tag:
<li class="hide" filter-type="aspect" data-unique="false" data-searchable="false" ...
-1
votes
0answers
26 views
Java Continuously read from active sockets [on hold]
I'm basically programming a game server to use for a RPG game, I'm doing all within Java 8 and Socket.
So to the point; I am listening incoming connections from a single thread, if the connection is ...
-1
votes
0answers
24 views
How to retrofit a program using log4j to use logstash instead?
I have a legacy java program that uses log4j. I would like to use the centralization features that logstash provides. How can I do this without modifying the original program? I don't have any ...
3
votes
1answer
165 views
How should I annotate, that a class is immutable in Java?
I recently stumbled upon how useful immutable objects are and that e.g. if you pass elements to a constructor and your class should be immutable, you have to copy these elements if they are not ...
2
votes
1answer
100 views
Does the JVM's Garbage Collector clean the entire JVM HotSpot memory (C-Heap, Java Heap and Permanent Generation space) or just Java Heap?
I know that the JVM has some JVM HotSpot memory which is further divided into three areas:
Java Heap
Permanent Generation Space
Native Heap (C-Heap)
I know that Java has automatic garbage ...
2
votes
2answers
217 views
Do wildcards in Java generics restrict or increase flexibility?
I have read many sources about wildcards and Java generics. Even though I have seen many explanations and answers, none of them seems correct.
The question is very simple: Do wilcards in Java ...
1
vote
1answer
141 views
Most efficient way of searching very large strings of text in java
I have a question that I have been thinking about recently but I am still not sure of the answer(s) so I would like a broader opinion.
Imagine the scenario where text strings of up to lets say ...
-5
votes
0answers
16 views
Which files have the extension .jspa [on hold]
I have seen websites with extension jspa. Is there a specific framework that uses this extension as default. Please can someone elaborate. Thanks
22
votes
4answers
3k views
Why doesn't Java have optimization for tail-recursion at all?
From what I have read: The reason is because it is not easy to determine which method will actually be called as we have inheritance.
However, why doesn't Java at least have tail-recursion ...
0
votes
3answers
262 views
Overriding equals() method in Java
Short question: Why does Java allow overriding equals(), why is it not final?
I am reading Effective Java 2nd edition by Joshua Bloch.
I am a bit baffled by the conclusion that
There is no way to ...
0
votes
0answers
78 views
C++ as a first Language [closed]
I recently signed up for a C++ course at my University with no prior programming knowledge. I realize, NOW anyways, that I should have taken a prior programming course, as I get lost in the concepts ...
0
votes
0answers
39 views
Multiple 1024x1024 texture pages or one 2048x2048 texture page?
I have a lot of textures around the size of 512x512, and the LibGDX texture packer can't find a way to put more than one of those on one page for some reason. So, I end up with fifteen or sixteen ...
-4
votes
0answers
83 views
What advantages and disadvantages does Gherkin provide when writing test automation? [on hold]
Suppose in my [agile] company our main goal is to automate manual tests.
The people that would write the tests are either our developers or QA people.
Our QA people know some Java, and the company and ...
0
votes
0answers
29 views
Does the zero that follows the fractional second part of a Jodatime formatted Date changes its Comparable order? [migrated]
Given two strings:
a) 2013-05-02 02:11:05.24
b) 2013-05-02 02:11:05.240
Does joda time interpret these two to have the same Comparable order ? i.e. they are equivalent.
-5
votes
0answers
64 views
I want to become an entrepreneur, which language suits my purpose? [closed]
First and foremost, i would like to say that i am already learning HTML and css. I realize that these are not programming languages, but one of the first things i want to do this year is learn to ...
-2
votes
1answer
91 views
I am new to programming, where do i start to learn? [closed]
It was/is my dream to be a pro programmer and I am working hard to learn but i can't .
I just wanted to ask from where should I start and which language.
C/C++/C#/java or another ?
Please help !!!
...
-3
votes
0answers
21 views
login to programme java using hsqldb? [closed]
hi i need help in my programme i need to vérifier login from my database hsqldb to access to my programme in mysql everything is good bat in hsqldb is not wanting to work at all
i using hsqldb is ...
0
votes
0answers
4 views
Return message to Android client from java Server via tcp sockets [migrated]
I am a beginner in Android with intermediate Java programming skills. I am also just learning socket communication. I am trying to make a very simple client/server connection. I have Android app as a ...
1
vote
2answers
143 views
Why can we use the same name for local variable in different scopes?
I was wondering why is it possible that we can use the same name for local variable in different scopes?
Like we can have two methods which both can have variable with the same name.
What makes ...
2
votes
3answers
95 views
Java logging dependency for a low-level library
I inherited a lower-level open source Java network library. The library is intended to be used by higher-level application protocol libraries which are in turn used by application code. My library, ...
1
vote
4answers
189 views
Use JSON objects or POJOs in back end service?
I'm building a back end service for mobile clients.
The requirement is that the mobile clients will pass me a token, I'll use that token to talk to other systems (behind the company firewall) in my ...
-4
votes
0answers
52 views
Why 1 bytes has 8 bits? [duplicate]
Past time Latin language was used in computer for giving command ,Latin language has 256 characters,for represent 256 word 8 bits was used .
2^8=256
8 bits are enough for representing 256 character .
...
0
votes
0answers
60 views
Java - Get Interface Generic Type
I'm trying to create an Interface with Generics which allows me to get the type of object in the generics but no matter what I try there's a syntax error. I've tried the following 3 methods.
All of ...
14
votes
5answers
1k views
How does one keep argument counts low and still keep third party dependencies separate?
I use a third party library. They pass me a POJO that, for our intents and purposes, is probably implemented like this:
public class OurData {
private String foo;
private String bar;
private ...
-1
votes
0answers
21 views
Best way to get data from database inside Thread Class in Spring [migrated]
Currently i am troubling that how to get data from database inside my thread class.
I can't make bean of my thread class because new instance is created of thread on every request.
MyThread.class
...
5
votes
2answers
431 views
When to fix something that is “wrong” but works fine
Short version:
I wrote some code that is not done "the right way" because, when I wrote it, I didn't know how to do it. Now that I know how to do it "the right way", how do I decide how to fix it?
...
4
votes
2answers
234 views
Is it a good practice to burn business logic into Enums?
Let's have a simplified business logic like this:
public enum BusinessLogic {
STAGE_ONE(true, false, false),
STAGE_TWO(true, true, false),
STAGE_THREE(false, false, true);
private final ...
0
votes
3answers
120 views
Should abstract classes be used to prevent instantiation
Is preventing the instantiation of a class a valid reason to make it abstract? For example, if I have a class called Gauge which has subclasses HeadingIndicator and AirSpeedIndicator, is it a good ...
-1
votes
1answer
82 views
How to identify http requests made from a closed-source java app?
I am an avid Go player and play on the Kiseido Go Server.
I would like to write an open source client for this, but the KGS protocol is a well-kept secret. Is there any way to catch the http ...
0
votes
3answers
181 views
Why Double.parseDouble(“ABC”) not returns Double.NaN?
This code:
Double.parseDouble("ABC")
throws a NumberFormatException.
Why is it wrong to expect a Double.NaN (NaN is literally Not-A-Number).
A working example is this:
public static void ...
5
votes
2answers
325 views
Small code, big test
I have this code in a controller of an MVC implementation:
public void execute() {
try {
String path = userSelectsFile();
if ( path == null ) return; //Just returns ...
0
votes
0answers
73 views
Best practices for programmatic describing of behavior of complex input forms
We have a complex web form (we use GWT/GXT stack) with lots of input elements of different types (text fields, selects, checkboxes, buttons), and behavior of these elements depends on each other.
Now ...
2
votes
5answers
711 views
Is it possible to make some methods invisible/non-usable to some classes in Java?
I am developing an application in Java whereby I would like to pass an object as part of an interface into other methods of classes written by other developers in the team. The object I'm passing in ...
1
vote
0answers
43 views
Java MVC: multiple use of the same event for different actions
I am working on a large Java project which employs the model-view-controller pattern. Should I use a different event for each action (to let the views communicate with their respective controllers)? ...
0
votes
1answer
43 views
Is there an established pattern for associating a database entry with a Java class that executes on that data?
I have a behavior tree with different leaf nodes that execute tasks. When building out the tree relationship in the database I need an association between the leaf node entry and the Java class that ...
0
votes
1answer
38 views
Architecture question about data migration
I'm facing a new enterprise project in Java about data migration.
I did one of them in the past, now I want to do a better work and I think I need your considerations.
So, let's me explain the ...
-3
votes
1answer
42 views
How should I change in get method without calling getList() of Deque? [closed]
import java.util.List;
import java.util.ArrayList;
public class Test {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
...
1
vote
2answers
126 views
Is it better to perform a calculation in the field's setter or have a different method?
I'm implementing a simple Quota object which determines a usage percentage based on the maximum and the used.
private int maximum;
private int used;
public Quota(int used, int maximum) {
...
0
votes
1answer
99 views
Enum as singleton or fully functional class [duplicate]
Joshua Bloch claims that
"a single-element enumeration type is the best way to implement a
singleton"
Why? I totally disagree with this statement because enumeration is data type with some ...
-1
votes
0answers
23 views
How BeanPropertyRowMapper works internally in spring?
I know that BeanPropertyRowmapper use setter method when I fire select query but is it uses getter method too or not ?
I don't want to make my custom row mapper or hibernate or JPA.
I have face below ...