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

-1
votes
0answers
6 views

eclipse acting weird when creating methods [migrated]

I don't see what could be wrong here, I was working on a different method but had some problems so I tried to simplify it to check where could the mistake be but I ended going up into this very simple ...
2
votes
1answer
121 views

Does the LGPL apply if I rewrite a portion of JasperReports in C++?

I would like to rewrite a portion of the JasperReports library in C++. The library will read from the same XML format used by JasperReports. If I integrate this C++ library to my proprietary ...
0
votes
1answer
89 views

Should a comparison method ever return the same type back as it's comparing?

First, this is homework, but no, I'm not asking for anyone to do any code for me. My course start date isn't for another month (it's online), so I can't ask for clarification. I thought I'd see if ...
-5
votes
3answers
107 views

Is it possible to Style a csv file? [closed]

I am generating a csv file in java and want to use MS Excel to read it. Unfortunately it looks very simple, with no formatting. Is it possible to add styling to a csv file (using java) so that when ...
0
votes
1answer
118 views

Changing the Garbage Collector on your JVM [closed]

My understanding is that the JVM specification only defines the behavior of a garbage collector, but does not provide implementation details. This means it is up to the JVM implementation to build the ...
2
votes
0answers
77 views

Cross-compiling Java app to run directly on ARM

Please note: although I am using ARM SAM3X8E in this example, I'm just using that as a concrete example, and the answer to this question could easily be given using any other MCU such as AVR, etc. I ...
2
votes
0answers
34 views

Embedded tomcat cold deployment without service disruption

I have the following scenario. For various reasons I chose to use embedded tomcat for my rest backend that will form a cluster of AWS machines. I will want to deploy fairly frequently updates ...
0
votes
2answers
124 views

What is the best type to represent a number in java and why? [closed]

I am developing a dynamically typed, interpreted programming language, which is interpreted by a runtime written in Java. As Java is statically typed, I need to define how the numbers used in the ...
3
votes
1answer
56 views

Do I need a web-service for this case? Data-synchronization over multiple clients

I'm new in this area and a little bit confused about my current thoughts on a web-service implementation for my application. I want to synchronize all connected clients with the current data on a ...
1
vote
1answer
46 views

role based access control model in object oriented

I want to prepare a swing application. I am designing a role based access control model in mvc design. When a view wants to request something from a controller, how can this request be realized in ...
1
vote
1answer
108 views

Java partial enum backed by the database

I have following problem: need to use enum in my java code, since I'll have to ask in my business logic things like if(someting == enumname.VALUE_ENUM){... but I don't have all the enum types at the ...
9
votes
6answers
399 views

Does it always make sense to “program to an interface” in Java?

I've seen the discussion at this question regarding how a class that implements from an interface would be instantiated. In my case, I'm writing a very small program in Java that uses an instance of ...
3
votes
1answer
121 views

What was the date of the Java Alpha and Beta releases

The date of the public 1.0 release of Java is easy to find: January 23, 1996. But there were public Alpha and Beta releases before that, and in December 1995 Java already appeared on the list of Time ...
4
votes
1answer
208 views

Is Collection.stream().filter().forEach() inefficient compared to a standard for each loop?

IntelliJ IDEA recommended to me just now to replace the following for-each loop with a Java 8 "forEach" call: for (Object o : objects) { if (o instanceof SomeObject) { ...
0
votes
0answers
23 views

Classes, Datatypes and replicating Methods [duplicate]

I've gone from writing code procedural-style to object-oriented recently and during my development as an object-orientated programmer I have made a few mistakes. What I have been doing is, inside my ...
10
votes
2answers
437 views

Java: why is there a Comparator interface but no Hasher and Equator?

This issue is most apparent when you have different implementations of an interface, and for the purposes of a particular collection you only care about the interface-level view of the objects. For ...
26
votes
4answers
2k views

Why is .compareTo() in an interface while .equals() is in a class in Java?

I want to know why the .compareTo() is in the Comparable interface while a method like .equals is in the Object class. To me, it seems arbitrary why a method like .compareTo() is not in the Object ...
3
votes
2answers
114 views

Best strategy to find the root cause when exception is swallowed by 3rd party

I am sure we have all run into a scenario where a 3rd part API complains with an incomplete stack trace. In essence the error handling in the 3rd party API does something like this, catch ...
0
votes
1answer
39 views

Is there any reason not to allow negative numbers to be entered into a JSP field labeled for positive numbers?

Our application, a fairly complicated money ledger, has a JSP field for entering a certain type of money due, balanced by payments made towards that amount due. In the application, this field is ...
-1
votes
0answers
37 views

Spring Java based configuration

I am trying to write web application in java without using frameworks, but decided to use Spring for request handling layer. In that case should I configure Spring in a different way than as in case ...
1
vote
2answers
29 views

Application model management questions

Consider the following type of Java / Spring web application, with an SQL database: there are multiple data entity types (about 100) with relations between them the entities are viewed, edited or ...
-3
votes
1answer
26 views

Connecting to MySQL with JDBC through Network

I have a desktop application that access the mysql database through Local Area Network. Do i need to install xampp mysql on client computer in order to access mysql database on another computer?
4
votes
4answers
325 views

Legitimate cases of having .equals() behaving inconsistently with .compareTo()?

Java documentation says it's "strongly recommended" to have them behaving consistently. But are there legitimate cases of java/c#/python/etc Object.equals() method behaving inconsistently with the ...
0
votes
0answers
15 views

Filtering data with CriteriaBuilder to compare enum values with literals not working [migrated]

I have a java class with a enum field, org.example.Importacion { ... @Enumerated(EnumType.STRING) private EstadoImportacion estadoImportacion; public static enum EstadoImportacion { ...
-3
votes
0answers
16 views

Why not successful “ HTTP GET request with socket ”? [migrated]

I want to send GET message at my Android application. After I want to receive GET response as 200 OK. But I didn't accomplish. I received 408 Request Time-outDate or nothing. Can you help me? String ...
-4
votes
0answers
28 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
36 views

ClickHandler for button = strategy pattern? [closed]

If you provide a implementation of a ClickHandler interface to a button (defining some behaviour), is this the strategy design pattern?
-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 ...
1
vote
1answer
97 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 ...
3
votes
3answers
251 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 ...
0
votes
2answers
103 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!"); ...
1
vote
2answers
94 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 ...
2
votes
3answers
179 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 ...
-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 ...
30
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 ...
-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 ...
-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 ...
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
2answers
212 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 ...
29
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 ...
-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 ...
19
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 ...
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 ...
18
votes
5answers
1k views

If Scala runs on the JVM, how can Scala do things that Java seemingly cannot? [duplicate]

I just learned about Scala yesterday, and I'd like to learn more about it. One thing that came to mind, however, from reading the Scala website is that if Scala runs on the JVM, then how is it ...
-2
votes
0answers
11 views

Java SWING: JList holding multiple Components as a single item [migrated]

Here is my problem: I'm creating a window that is responsible for listing a layer, where it displays the layer's current image (in the form of a ImageIcon as of now), layer's name, and a checkbox to ...
2
votes
1answer
48 views

Keeping lists of Objects, some with, some without inheritance

Let's say I have two classes, Foo and ExtendedFoo where ExtendedFoo inherits from Foo. Foo has a method .getValue() which returns a number, ExtendedFoo also has .increaseValue() which adds to the ...
-2
votes
0answers
23 views

Finding the sum of columns in a Two Dimensional Array with rows of different lengths [migrated]

So i'm having a bit of trouble with my code in returning the sum of the columns in a two dimensional array with rows of different lengths. For example a 2X2 array works perfectly to calculate the sum ...
4
votes
3answers
221 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 ...
-2
votes
2answers
131 views

Is this a good game plan to become a fluent Java developer? [closed]

I am an efficient person, and I am trying to find the best method of becoming a great Java developer. Here's what I'm thinking: First, learn syntax and Object Oriented concepts. Practice it, and ...