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

0
votes
0answers
47 views

Passing values from custom columns [on hold]

This question is a bit subjective so the intention is to get some feedback on a problem I'm experiencing and ways around it. The kind of answer I'm expecting will answer the question "what are good ...
0
votes
0answers
25 views

Status updates design review [migrated]

I need help identifying any significant design issues with some code I have generated to track status updates. I have a big task A which contains multiple small tasks and each of these small tasks ...
0
votes
1answer
106 views

How do different technologies connect to form a web stack? [closed]

I am a little confused, is it possible to implement a front end using common languages like html, css and javascript and then do server side processing using a language of your choice, say python or ...
1
vote
1answer
132 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? ...
1
vote
0answers
55 views

How to pass control between sub-controller to parent controller in Java MVC Design Pattern?

I'm pretty new in Java, but I've done plenty of research and I know what MVC is. However, to implement MVC in Java was a difficult task. I followed this tutorial, which helped me to realise that the ...
5
votes
2answers
280 views

Why can't I understand Java? [closed]

I'm a 9th grader and I joined my school's robotics team in order to learn how to code Java and enter the programming team. However, I am so confused! Even after the first lesson, I had no idea what ...
-5
votes
1answer
49 views

How best to design a SQL Parser in java, any prevailing design pattern comes to mind? [closed]

What software pattern is most useful for building a SQL Parser? I would like some ideas on how to even get started on something like this.
3
votes
1answer
101 views

Should a class explicitly implement interface if its superclass also implements it?

Given an interface interface I { one(); two(); } An abstract base class partially implementing I abstract class A { @Override void one() { //something } } And lastly ...
-2
votes
0answers
53 views

Selling the idea of using Python vs Java for offline batch jobs [duplicate]

I need to make a case to my team why we should expand our technology spectrum onto Python. We currently use Java with JBoss and JSF/PrimeFaces for our mission critical, user-interactive web ...
-1
votes
0answers
8 views

H ow to take more than two words from a textField at different times [migrated]

I have this code which I one textField and want a user to be able to type through the words in a sentence, like a typing test pressing enter after each word entered. The first word the user typed ...
0
votes
3answers
346 views

Can regexp be used to check for palindromes?

Can regexp pattern matching be used to check for palindromes within a given text in Java? My intuition is that in order to check for palindromes, we may need to remember the character that was ...
-5
votes
0answers
16 views

Reopen request - Will java be relevant in 5 years? [migrated]

I don't have enough rep to post in meta. I'd like to know if this (4 year old) thread could be reopened. Will Java still be relevant in 5 years? Java is taught in the intro to Computer science ...
0
votes
0answers
39 views

Is this interpretation correct on usage of interface? [migrated]

We have numerous threads talking about the usage of interface vis-a-vis abstract class Taking reference of an answer, given by Prasun looks complete answer to me. Do you think this is complete ...
0
votes
1answer
166 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 ...
1
vote
2answers
292 views

Programming against interfaces in Java

Supposing I have an interface Foo and a given implementation FooImpl. public class FooImpl implements Foo If I want to define a new operation on this class that depends on the particular ...
1
vote
1answer
146 views

Should CountDownLatch be used for waiting for an event?

I have a situation here, where I have a loop that loops x amount of times. The value x is determined by the user. Everytime it loops, I want it to wait for a button click before continuing the loop. ...
-4
votes
0answers
20 views

How to have a command line print out a text document in java [migrated]

I'm currently coding a choose your own andventure and in java and need to have the console print out a number of text documents. Currently I have File myFile1 = new File ...
0
votes
5answers
189 views

Race conditions in JVM languages versus C/C++

I was thinking about thread synchronization issues in compiled languages like C++, versus synchronization issues in languages like Java. I'm wondering how a JVM language like Java doesn't (at least ...
0
votes
1answer
171 views

2D Game Data Structure in OpenGL ES 2.0

I'm trying to come up with some data structures for rendering my map on OpenGL. It is going to be ~ 100x100 blocks(squares) total, with each block being around 100 pixels. However, the screen will ...
0
votes
1answer
310 views

Emulation of MMU accessing the contents of the registers

I'm having a play around with emulating a simple old CPU. I've set the structure up, so far anyway, as follows: The device is the main and creates an instance of the CPU. The CPU then creates ...
7
votes
5answers
710 views

Coding style issue: Should we have functions which take a parameter, modify it, and then RETURN that parameter?

I'm having a bit of a debate with my friend over whether these two practices are merely two sides of the same coin, or whether one is genuinely better. We have a function which takes a parameter, ...
3
votes
4answers
2k views

Which design pattern is more suitable for logging?

I should log some events in a program but as far as I know it would be better to keep the logging code outside the program because it is not about the real functionality of the program. So may you ...
17
votes
3answers
2k views

How to solve the problem of nested comments

It appears in not just one language that comments can't be nested. Do you have a good solution for this problem? One workaround in C/C++ and Java is to only use the single-line comment but it becomes ...
44
votes
7answers
29k views

Why use try … finally without a catch clause?

The classical way to program is with try / catch but when is it appropriate to use try without catch? In Python the following appears legal and can make sense: try: #do work finally: #do ...
0
votes
0answers
17 views

Java two for outer for loops with two inner for loops that add to a string and the first one doesn't do anything [migrated]

public static void diamondOfAsterisks(int numOfRows){ String diamondStr=""; for (int row = 1; row == (numOfRows/2+1); row++){ for (int space = numOfRows; space < row; space--){ ...
1
vote
3answers
225 views

Including extra headers that I do not really need

I always wondered what are the effects of including not needed headers to the final executable once compiled. In my code some times I may included many different headers that I do not need (or I used ...
26
votes
11answers
10k views

Is it good practice to catch a checked exception and throw a RuntimeException?

I read some code of a colleague and found that he often catches various exceptions and then always throws a 'RuntimeException' instead. I always thought this is very bad practice. Am I wrong?
40
votes
6answers
7k views

Why was C# made with “new” and “virtual+override” keywords unlike Java?

In Java there are no virtual, new, override keywords for method definition. So the working of a method is easy to understand. Cause if DerivedClass extends BaseClass and has a method with same name ...
0
votes
2answers
190 views

calculate complexity of LinkedHashSet

I have an ArrayList<LinkedHashSet<String>> setOfStrings for example this arraylist internally is composed like: positionX[hello,car,three,hotel,beach] positionY[.....] ... I want to ...
1
vote
1answer
275 views

Refactoring Tomcat webapp deployments

Background We have several webapps running on Tomcat 7.0.x (on Linux). For historical reasons, we have populated the "Common" lib (i.e. $CATALINA_HOME/lib) with many application jars. These jars ...
0
votes
0answers
8 views

Can't find main class in Java? [migrated]

For some reason that I haven't been able to figure out, the program I've been working on for a while now isn't running. This is the error message I've been getting: All I did between the time it was ...
-2
votes
0answers
17 views

How to change the return message of Exception.getMessage()? [migrated]

I need to change the return message of the method getMessage() , for instance, i have an ArithmeticException, and when i write: try{c=a/0;} catch(ArithmeticException excep){System.out.println( ...
-1
votes
1answer
64 views

Creating a new type of project file [closed]

I'm starting to work on a project where it would be quite useful to have something like a project file that holds all the data being used in a form that can't be opened/modified/used in anything but ...
0
votes
0answers
4 views

how to use postgresql in Java [migrated]

I Installed postgresql and its driver which is "postgresql-9.3-1102.jdbc41.jar". And my directory seems like : > SQL > myJDBC.java > postgresql-9.3-1102.jdbc41.jar I have tried : ...
-1
votes
0answers
11 views

i am trying to sent sms through serial port event listener but i am grtting this error NoSuchPortException [migrated]

Week before this code working perfectly but after formating the system it is giving NoSuchPortException while trying to send sms connect my nokia c3 cell phone via usb error log is as enter code ...
0
votes
1answer
113 views

Logic based on modified fields of a Hibernate entity

I have a Hibernate entity object MyObject with several attributes and a service MyObjectService containing business logic dealing with MyObject. I also have a view model dealing with user input/output ...
0
votes
0answers
70 views

How to micro-ify the middle tier in a Microservice Oriented Architecture?

Just read Fowler on Microservices and definitely recommend it. A big thing that is missing from this paper/approach is how to decompose the client-tier into "micro apps". By that, here's what I mean: ...
0
votes
1answer
119 views

Which package should unrelated classes belong to in Java? [closed]

In a project, certain related classes can be grouped together in one package. But some other useful classes are not related to any other class and so cannot be put into a package with any other ...
0
votes
2answers
204 views

Why use Creational patterns in Java?

How are Creational patterns useful? Most of the material I came across explains the use case to "solve common problems associated with object creation, improve flexibility". I can think of just two ...
2
votes
2answers
104 views

Designing a system to archive databases with referential integrity

I have a very large Oracle database, with many many tables and millions of rows. I need to delete some of the rows end-to-end. By end-to-end, I mean, if I want to delete a row from a table then I must ...
0
votes
1answer
109 views

Spring web application deployment infrastructure

I'm interested in hearing out what's out there in terms of tips and tricks on deploying and maintaining a Java web application whilst keeping agile. I'm running solo on a startup project I'd like to ...
17
votes
4answers
2k views

Using public final rather than private getters

I see most immutable POJOs written like this: public class MyObject { private final String foo; private final int bar; public MyObject(String foo, int bar) { this.foo = foo; ...
0
votes
0answers
72 views

Java 8 Streams API HAVING clause equivalent in a GroupingBy? [migrated]

I've run into a hard to solve problem in Streams API. Well, it is solvable but not elegantly within a single call from what I can tell. Below, taking a stream of FeatureContentWeight objects, I want ...
0
votes
1answer
68 views

Cleanest choice for symmetric operations

I have a need to do some processing from a format A to a format B and from B to A. The job in one direction is very similar to its counterpart. Both formats are represented with an interface Msg. In ...
4
votes
2answers
911 views

How does MVC work with the principle “Tell, Don't ask”?

Procedural code gets information then makes decisions. Object-oriented code tells objects to do things. — Alec Sharp So, when a view wants to display some information that is suppose to be ...
1
vote
0answers
45 views

Incorporating custom Algorithm in SOLR-LUCENE , before Indexing?

CURRENT FLOW: I am using a custom algorithm(presently in php) to rank the MYSQL records before INDEXING it to SOLR . WHAT I WANT : Is it possible implementing this ALGORITHM(may be in JAVA) inside ...
50
votes
7answers
6k views

Should a getter throw an exception if its object has invalid state?

I often run into this problem, especially in Java, even if I think it's a general OOP issue. That is: raising an exception reveals a design problem. Suppose that I have a class that has a String name ...
0
votes
1answer
259 views

problem on calculating Big O complexity

i have this function on which i have to calculate the time complexity with the Big O notation: public void print(ArrayList<String> operations, ArrayList<LinkedHashSet<String>> ...
-2
votes
1answer
61 views

Naming of classes [closed]

I am creating an Email sending client. My POJO domain model conssts of 2 string fields, userName and userId. My thought process around designing the classes was to club these 2 fields into a domain ...
27
votes
2answers
1k views

How have Guava unit tests been generated automatically?

Guava has unit test cases automatically generated: Guava has staggering numbers of unit tests: as of July 2012, the guava-tests package includes over 286,000 individual test cases. Most of ...