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
3answers
108 views

Why not make everything private or public? [on hold]

In code there are private and public declarations. Why shouldn't I make everything private or make everything public?
1
vote
1answer
41 views

detecting website opening in new tab/window?

So, as part of my final year project, I'm writing a web crawler in Java to gather website data that I will then process. One of the attributes I need to gather is "number of popups". I know a pop-up ...
-3
votes
0answers
13 views

Multipart file upload vs chunked upload [on hold]

There are lot of suggestion when uploading files with large size to use multipartfile or chunk the file and do upload. Can someone suggest which one to follow. Also any links to the example is ...
0
votes
3answers
94 views

What is a good strategy for reading XML like hiearchical text data?

I want to read data in a format like the following using Java. [scenario] id=my_first_scenario next_scenario=null name=_"My First Scenario." map_data="{~add-ons/my_first_campaign/...
4
votes
1answer
65 views

The bound mechanism by generics for a type variable to appear in its own bound

From Programming Languages: Principles and Paradigms By Maurizio Gabbrielli, Simone Martini The bound mechanism for type variables is fairly sophisticated and flexible. In particular, a type ...
0
votes
1answer
58 views

Find best subcombination from given combination

Each component has multiple possible states and any number of them can be active at a time. Some combinations of states have a value associated with it. At any given point, it wants to be able to get ...
0
votes
1answer
121 views

Is it OK to use class names in an interface definition?

I am creating interface in Java for custom error handler. Want to pass an argument error object but I need it to be child of Exception class. Is it okay to use my defined class name in an interface ?...
0
votes
0answers
10 views

How to make serializable polymorphic relations with Spring JPA

Say, I have an entity, named Attachment in my DB. It describes a file attached to some other entity - an issue, a wiki-page, a test-run or whatever - i.e. it may be linked to objects of different ...
3
votes
2answers
108 views

How to build a class for comparing words in a lexical dictionary?

I'm wanting to create a class that stores words in a set so that I can see if a word belongs to that set or not. I'm not wanting to build ever set every time I instantiate the class, so I'm using what ...
-2
votes
3answers
77 views

How is typecasting an array different from typecasting an individual element?

is the following code snippet: String[] str = {"Abc","Ghi","Def","Mno"}; Object[] obj = str; String[] p = (String[]) obj; same as : String[] str = {"Abc","...
1
vote
0answers
37 views

How is memory modeled in projects like Apache Spark or Druid?

In the past couple of months I've worked with both Apache Spark and Druid for some projects. As I've gone through the process of learning how to use these tools, I've spent some time reading through ...
0
votes
0answers
26 views

Implementing my own Integer.toBinaryString(int n) method [migrated]

Our senior developer gave us (trainees/jr. developers) a small exercise and that is to make our own Integer.toBinaryString(int n) implementation. This is the answer I came up with. I would just like ...
3
votes
2answers
127 views

Design pattern for free / premium user role

this question is actually about a complex java project I am doing at university, but it is possible to find a simple case which is really similar to the problem I am facing. In this scenario, we have ...
3
votes
5answers
407 views

Start Method vs. Setting up everything in constructor

The internal framework my company uses has a pretty pivotal Object that has a pattern of being instantiated as a member of a class with a no argument constructor but to be usable you have to call a ...
0
votes
0answers
65 views

Is a General Exception In Addition To Expected Exceptions Defensive or Unecessary?

I have read this and this and this: if my question misses the point in those answers, please point it out and we'll get this one deleted. These questions indicate that this may actually be a bad thing ...
4
votes
1answer
64 views

Design verification - chat application architecture

So for my newest hobby project, I want to create a simple chat application where users can just log in with a nickname (no passwords) and talk to anybody on the network. Off the top of my head, I'm ...
3
votes
1answer
75 views

How to make a webdriver run reliably in Selenium?

I have been having quite a time getting this to work reliably for 100s of thousands of terms and potentially millions of pages per source and ETL the resulting data into a database in an automated ...
1
vote
2answers
97 views

Java Generics, difference between two methods signatures with wildcard vs type parameter

I'm having a hard time trying to figure out why the two methods declarations have different results. On the first method signature its obvious you can't compare Apples with Apples and Oranges with ...
0
votes
0answers
34 views

Back-end structure for a specific described mobile application?

I want to design and implement a mobile application in which: Every user who have already registered is able to add new news (including title: text plus a picture, and content: long text, pictures or ...
5
votes
8answers
665 views

Why don't constructor return bool to indicate its success or failure without having to throw an exception?

Take C++ constructors for example, we know they don't return values. Why did Bjarne Stroustrup in the beginning decide not to allow constructor returning 'false' to indicate it fails, so that the run ...
0
votes
1answer
42 views

Storing data in reverse order in an array based list efficiently

Hi I have a data structures programming project involving creating my own array based list and then efficiently storing String read from a file but in reverse. So that arr[0] = the last line of the ...
1
vote
1answer
50 views

Java Overloading/Inheritance

I've been trying to get a clear understanding of what the end of the follwing code outputs: class C { public int foo(C p) { return 1; } } class D extends C { public int foo(C p) { return 2; } ...
-3
votes
1answer
94 views

Assigning variables as lines of code

I know in lua you can do something along the lines of print=System.out.println print("Hello") But is there something similar in java?
0
votes
0answers
57 views

Are there any downsides to JavaFX Properties as a replacement for Beans?

So I am really annoyed that Java doesn't support C# like properties. I tried a lot of things to emulate that behavior and this is the best I came up with: import javafx.beans.property.*; //immutable ...
1
vote
1answer
84 views

Why does C#'s System.Threading.Semaphore implement IDisposable and why doesn't java.util.concurrent.Semaphore implement Closeable?

In .NET framework, System.Threading.Semaphore is a IDisposable that require manually dispose. However, in JavaSE, java.util.concurrent.Semaphore is not a Closeable nor a AutoCloseable. Why do they ...
-2
votes
1answer
87 views

How does accessing class level variables in java work?

I'm doing my third online course in learning java because I couldn't get over how to even start a project from scratch. There was a lesson in this new course that made me ask this question of the code ...
2
votes
1answer
193 views

Why do we need stacks and queues?

I don't see the reason to have classes for stacks, queues and deques if we have the data structure linked list, since a linked list can act as both a stack and a queue (and always has the functions of ...
3
votes
2answers
296 views

Understanding the need of Visitor Pattern

After seeing an article on visitor pattern, it is clear to me how it works. And I created a sample program for my understanding; main(){ SortingAlgorithm bubbleSort; : intList.sort(...
1
vote
0answers
42 views

Architecture recommendation for Android

Recently I developed Android application which is very difficult to maintain and We stuck in complicated situation. We developed Android Apps which contains 500k LOC and another team developed same ...
-2
votes
0answers
75 views

Applying patches to already deployed software

I focus on Java platform, and I would like to know how patches are applied to already up-and-running (deployed) software, from Java's point-of-view. The answer(s) should consider: possible techniques ...
0
votes
0answers
4 views

Java / JPA - Challenge of how to SELECT using use large binary out param from a stored procedure [migrated]

I have the following requirements: Call SQL Server stored procedure that has a varbinary(max) out parameter with a size > 8000 bytes Pass the varbinary(max) out parameter to a SQL Server function on ...
-2
votes
1answer
116 views

template restrictions in C++

I am creating a template class in C++ for numeric operations and I want to restrict it to only numbers or similar numeric types. My question is that is there any way in C++ to restrict a template ...
1
vote
0answers
89 views

Is Pairing a bloated interface with an Enum a good idea?

At work we have an interface that is getting bloated. The interface is designed to be easily implemented by an immutable object. So it looks something like this: //there is no behavior here, just ...
6
votes
2answers
169 views

Is there any disadvantage to using Eclipse Collections exclusively?

Because my application works with very large collections of integers, Eclipse Collections seems like a very useful framework because of its primitive collections. I've tested it already, happy to see ...
0
votes
2answers
78 views

Small Search Engine Algorithm for Document Word Search

I have to design and implement an algorithm for my university project that searches a given set of documents based on the keywords/query given. Assume that each document contain few sentences and ...
0
votes
3answers
216 views

Mental model for working with linked list [closed]

I have been doing some practice problems on LinkedList but more than half of my time is spent on managing null pointer issue in my code, provided I have to keep track of current, previous and runners ...
-3
votes
0answers
40 views

How to update mobile application using a web-portal database server (content management system)?

We would like to develop a mobile application that will have a web-based for administrator or Content Management System. All database will be saved at the CMS, like all input informations from mobile ...
-1
votes
2answers
143 views

Java - is it bad to name variables starting with uppercase if they are vectors or matrices? [closed]

Often in math a vector or matrix will be denoted by a single capital letter. Would it be bad to have some variables such as this? Vector3 A = ... int Bx = ... int By = ... int Bz = .. I would ...
-3
votes
0answers
30 views

Comparing runtime flows when hunting for a bug

A (big) change in my (big) project introduced an error. I can reproduce it in my own development branch, but all is OK in the master branch. Is there a tool that allows for recording the runtime ...
-2
votes
1answer
51 views

Rotate a matrix in place, moving elements? (How to write a part of flow/logic after understanding the problem?)

Following is a java solution of the classic question of rotating a nxn matrix in place clockwise by 90 degrees. public void rotate(int[][] matrix, int n) { for (int layer = 0; layer < n / 2; ++...
-2
votes
2answers
60 views

Operators precedence in java (unary plus and addition) [closed]

I'm having trouble in figuring out why the output for theses two lines is different .. public static void main(String[] args) { System.out.println("6.0+1="+6.0+1); System.out.println("6.0+1="+(...
0
votes
2answers
59 views

Static members and finalize( )

If we have a code snippet like: public class Finalizer{ static List list = new ArrayList(); public void finalize( ){ System.out.println("hello"); } } What is so special about ...
1
vote
1answer
39 views

Explicit call to finalize() method in Java

I was reading about finalize() method that it may be invoked automatically when an object is eligible for garbage collection.Now this uncertain.But what happens if we call it explicitly.Does it ...
1
vote
0answers
83 views

Improve performance with recursive apporach in quaternary numeral system [migrated]

How can performance be improved with the following approach to determine n=3 results in a(3) = 42: 000, 002, 003, 020, 021, 022, 030, 031, 032, 033, 100, 102, 103, 110, 111, 113, 130, 131, 132, ...
2
votes
2answers
156 views

Is a linked list considered a collection of objects?

Sedgewick's Algorithm 4ed says Several fundamental data types involve collections of objects. Specifically, the set of values is a collection of objects, and the operations revolve around ...
3
votes
1answer
60 views

Pass Objects or values as parameters to functions

I'm working with JEE standard. I have the following layers: JPA (Eclipse Link), Data Access, Business Logic, and JSF (Primefaces). Primefaces uses MVC design pattern, so the the presentation layer ...
4
votes
2answers
219 views

Java Design Philosophy

I was reading through design philosophy of java and this line struck me: "The VM checks whether the signature of the Java code is valid and would refuse to interpret if any change of the code is ...
7
votes
2answers
263 views

Separating Business logic from DB-logic with transactions

We have three layers in our application. Service layer to provide an external API. BO layer for our business logic, and a DAO layer for our database connection. Let's say every time we update a File,...
-2
votes
1answer
94 views

I'm trying to create a file with all possible outcomes of tic tac toe and store it using java. How do i do it?

I'm trying to store more than 512 combinations of a game somewhere locally on my hard drive as a single file permanently unlike the temorary nature of arrays. If I store it in a text file like I ...
3
votes
1answer
115 views

In OOP which object is common to update the state of an object when working with State Machines?

I'm about to implement my first State Machine and I'm left with one question, which is the acceptable coding form on who should change the state of the object/entity? Should the StateMachine change ...