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
1answer
17 views

Most Efficient way to Compute the sum of divisors of N (1 ≤ N ≤ 1 000 000 000)

I want to write a code which computes the sum of divisors of a number N(1 ≤ N ≤ 1 000 000 000), excluding the number itself. However, I need an efficient way to do it. It suppose to print the answer ...
0
votes
0answers
12 views

Query on Recursive composition

For the below relation between Container and Componentin java.awt class hierarchy, I see that, in addition to is-a relation, class Container has composite relation with class Component with below ...
0
votes
1answer
60 views

Does class Availability makes programming as Object Oriented Language? [duplicate]

Does class Availability makes programming as Object Oriented Language ? Most of the people think that if there is Availability Class in a language, then that language becomes Object Oriented. Is it ...
0
votes
0answers
61 views

Should I choose to become a java developer or web developer? [on hold]

I'm still in college and have developed interest towards both java development and web development. I have the desire to work as both, but I fathom that is not how the industry works. This brings me ...
2
votes
2answers
136 views

architecture of database heavy application

A program I'm currently designing is extremely database heavy, almost anything the user does will alter the database, or read from it. Now I have one interface which defines all these operations, and ...
0
votes
1answer
71 views

Starting Execution of Java Program

While reading about Java Programming I couldn't get why it states Java static main necessity reason is because "before you're program starts,there aren't any objects to send messages to" as said in ...
0
votes
6answers
186 views

Why 'String' objects are immutable with an explicit constructor in java?

It make sense to make class String objects immutable with following declarations, because they share the same storage in common pool. String str1 = "abc"; String str2 = "abc"; But, am not sure, if ...
0
votes
0answers
9 views

What is meant by end of stream reached in inputstream.read()? [migrated]

my android smartphone is tcpclient and chipkit wf32 wifi module is my tcp server. int bytesRead; InputStream inputStream = socket.getInputStream(); while ((bytesRead = inputStream.read(buffer)) != ...
0
votes
1answer
150 views

Where is it specified that Java is call by value?

I know that Java is by default call-by-value but I am not sure where in the Java Language Specification this is addressed. Google searching only seems to find me unofficial sources but never points to ...
0
votes
0answers
30 views

Transaction Management in Hibernate with DAO Design Pattern

I have many Tables, For every Table,we have DAO Interface and DAOImplementation class. Example DAO Interface public interface CancelPolicyDAO { public CancelPolicy insertCancelPolicy(CancelPolicy ...
2
votes
2answers
156 views

Are there other ways to limit recursion depth for a function?

I am trying to prevent a function/method (in Java) from performing recursion more than a depth of 3 self calls. I've learnt about the accumulator trick from odersky's scala coursera course. public ...
6
votes
2answers
229 views

Why shouldn't a method throw multiple types of checked exceptions?

We use SonarQube to analyse our Java code and it has this rule (set to critical): Public methods should throw at most one checked exception Using checked exceptions forces method callers to ...
1
vote
1answer
49 views

What are some best practices concerning separation of concerns and transactions?

I believe I know the answer to this but I'm looking for any holes or anything I may be missing. This is focused on Spring and Java but could really apply to any programming stack. Anyway, we have a ...
-3
votes
0answers
42 views

What is the property of -Xlint when compling a java program having vectors? [on hold]

When we compile a program containing the vector class in cmd, the statement javac Class1.java -Xlint What does this imply?
0
votes
0answers
16 views

Design architecture and software for webapp integrating with few other endpoints (Email Server, Jira, CRM system)

In my upcoming project, I need to integrate a webapp with few other endpoints. Main duty of the webapp will be some kind of thin-client for inner JIRA system for company. Moreover, I'll need to ...
0
votes
2answers
72 views

Java Web Application in Cluster with Shared Database. How to Negotiate an Instance to do Updates? How to Notify Instances of Updates? [duplicate]

I have a Java web application, running in a cluster of Tomcat application servers and a shared SQL/JDBC database. Data from the database is cached in memory in each instance of the web app. My web ...
0
votes
4answers
210 views

How to ensure objects unique by equality?

I frequently have this problem but didn't find it as an established programming pattern. I have some Class C whose equality is determined by some key k and I want to prevent time-consuming ...
1
vote
2answers
103 views

Can I use US-ASCII and UTF-8 encoding interchangeably for an XML file without a XML root declaration?

My source XML does NOT contain the root declaration i.e. <?xml version="1.0" encoding="utf-8" ?> And when I run the file command on it, I get: ASCII text, with very long lines, with CRLF ...
0
votes
1answer
106 views

calculating the average of a value over a month [on hold]

I am working on a project right now that is having me calculate monthly interest on a bank account. The way the interest is supposed to be calculated is as follows: Use the daily average to calculate ...
-1
votes
0answers
35 views

Moving from .net to Android - what is the best way for two apps I am developing? [closed]

I have been developing with C# for a few years. I would love to go the Xamarin route but management have decided against that (too many java developers in the company) and I have to start learning ...
-2
votes
2answers
104 views

Java 8 vs Scala? Which one to learn? [closed]

Scala has been promoted with advantages of perfect mix of functional programming and pure OOP and some more features which is difficult to achieve with java like reliable multi-thread programming. I ...
0
votes
1answer
176 views

Did Java avoid multiple inheritance here?

I learnt that Java did not allow multiple inheritance using abstract classes for simplicity. In java, after a good design of class hierarchy, SubType would not get into trouble of same method ...
0
votes
1answer
141 views

Why does this evaluation function work in a connect four game in java

I am exploring how a Minimax algorithm can be used in a connect four game. I was looking through a program and found this evaluation function. private static int[][] evaluationTable = {{3, 4, 5, 7, ...
-2
votes
0answers
27 views

Can Camel be used for building up html pages? [closed]

Is it possible and furthermore should it be done? If I have 10 web services that all generate different parts of a web page. For example header, footer and body elements. Should I use Camel or some ...
-4
votes
1answer
83 views

Learning Java. Planning to create my first java project. I have an idea for a logfile error aggregator (details inside), but how do I start? [closed]

I'm thinking of coding a 'Logfile Error Aggregator'. I'm not sure if it's anything useful or not, but it's something (possibly) practical: Assume there is a folder full of log files. Each file ...
1
vote
4answers
158 views

Java exception handling design

I am trying to design a simple exception handling strategy for web services middleware using some ideas from here: http://northconcepts.com/blog/2013/01/18/6-tips-to-improve-your-exception-handling/. ...
2
votes
2answers
129 views

Passing by value multiple times vs. Creating a public class variable

Suppose I have a series of methods across different classes that all use the same five core variables defined in my main method. I could chain these five variables as method arguments from one method ...
0
votes
3answers
192 views

I want to understand clearly why can't we instantiate an object of an abstract class [duplicate]

Can I get a clear explanation why why can't we instantiate an object of an abstract class. I know abstract is not real. But I want to know more why can't we instantiate an object of an abstract class. ...
0
votes
0answers
64 views

What is the best way to implement a workaround for Log4J's DailyRollingFileAppender issue on Windows?

I understand that there is an open bug with Log4J 1.2.x because (apparently) the java.io.File.renameTo() function fails due to a OS lock on the log file, which causes the file not to be renamed. I ...
4
votes
3answers
191 views

Batching immutable object changes?

With immutable models, what would be the best way to batch several changes? For example, let's have a Book that is immutable. I need to change both title and year. I could change one by one, but that ...
-1
votes
0answers
35 views

Making hard to hack java standalone apps [duplicate]

I created an app in java, but this app (packed as .jar) will be distributed to people, and I want to charge for usage of this app. I chose java as I'm unfamiliar with C++, to make a source code ...
1
vote
0answers
80 views

Streamlining a method to run faster [migrated]

Update: I did some guesswork tweaking and let the heap reach a maximum of ~450 Megabytes (was originally using invokeAll). The program just finished in 6.3 minutes. I've been advised to use ctrl + ...
0
votes
3answers
194 views

Java 1.7 library with a Java 1.5 program - what are the options

I have a class library which is compiled with JDK 1.7 It uses several 1.7 features and classes and would be very difficult to get it recompiled in JDK 1.5. This needs to integrate with an old legacy ...
-5
votes
1answer
91 views

Help Understanding This? [closed]

I'm using the book Heads First Java and I just don't understand it at some parts and the book doesn't explain it well enough. Could someone please tell me what each line does? public class whileloop ...
1
vote
0answers
54 views

how to prevent mouse grab while debugging 3D application on a java IDE? [migrated]

Most 3D applications grab the mouse. This means the OS cursor is hidden and only the 3D application cursor is shown (and only within the application). In case it is a game, the cursor is completely ...
0
votes
0answers
4 views

working with the command prompt in Java [migrated]

I've been learning java on my own and I've come to a point where I need to pass arguments from the command prompt. I had previously been using Netbeans, which has become a bit of a crutch, but I want ...
-1
votes
0answers
78 views

How to properly close a Scanner class inside a method? [migrated]

I have this code that calls to a method in order to check if a number is a certain length, and if not, a new number should be reintroduced by the user. Problem here is, I can't find the proper way ...
-1
votes
0answers
34 views

Is this way to implement ECIES cipher's correct? [migrated]

I downloaded source code of cryptosms from http://cryptosms.org/download.html and implemented ECIES cipher in my work for Java mobile. I doubt validity of this step (full code of my method is below): ...
3
votes
1answer
63 views

Skeletal/Abstract class just to store shared state?

Given an interface for the Strategy pattern like so: public interface Strategy { public Output execute(Input input); public Output getLastExecutionOutput(); } if I want to store the last ...
1
vote
0answers
94 views

Is there a quicker method for returning a sublist after a certain index of a list in Java? [migrated]

I'm working on a program in which I will need to frequently truncate the beginning of a list, by just a few indices. (Sometimes, only one.) Then, the new list must be passed on to another method, ...
-5
votes
1answer
94 views

What is the purpose of Deprecation? [closed]

Is it just giving different names to previously named method? Does it change with the language you use? Is it essential? I have noticed different APIs having deprecated methods, which actually seem ...
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
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 ...
1
vote
0answers
56 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 ...
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 ...
5
votes
2answers
287 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.
-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 ...
3
votes
1answer
104 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 ...
-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 ...