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

-4
votes
0answers
27 views

If database is thier Why we use datastructures? [on hold]

we are using dbms and also data structure. both are used to store the records.In this we can use database.the dbms is enough for this why we are use data structures in the organsations.
-2
votes
0answers
52 views

Any tips for overcoming code quality obsession? [on hold]

So I'm self employed developer who works on commissioned projects. One issue I've seemed to develop over the last year is that I stress too much over the quality of my code rather than the finished ...
3
votes
0answers
27 views

How Should I Design JSON Serializable Data Classes To Respect Future @NonNull Fields

I have an app that uses Gson to serialize/deserialize data classes and persist data between runs. My code uses @NonNull annotations for many fields/parameters/method returns and one thing that was ...
0
votes
2answers
73 views

What happens to lock's state and methods when a thread acquires a lock?

Assume I have following class class Student{ void method1(){ // Do Something } void method2(){ // Do Something } } And the object of this class is used as monitor in ...
-4
votes
0answers
50 views

how does recursive backtracking work in this one? [on hold]

The question i encountered in this one :- Write a method countBinary that accepts an integer n as a parameter and that prints all binary numbers that have n digits in ascending order, printing each ...
-5
votes
0answers
35 views

I need to create a stock class [on hold]

I need to create a class called Stock on BlueJ, with 2 parameters each to be assigned to the "symbol" and "name" instance variables & there should be 2 "set" methods , one each for the ...
0
votes
0answers
10 views

Better way to wrap incompatible objects with default-method emulated traits?

In my Selenium web tests, I wrapped some elements and custom widgets with trait-like interfaces with default methods[1]. I want to add a caching feature to this type hierarchy to avoid repeated ...
1
vote
3answers
124 views

How does recursive backtracking work ?

I am trying to figure out recursive backtracking, i have good understanding of recursion and till some extent the concept of backtracking too but i am having difficulty understand the chronological ...
0
votes
0answers
65 views

What is the use of stateless object? [on hold]

While it is possible to create a stateless object, I am curious to know a use case or advantage of the same. If a stateless object is created for only providing the behavior then I would prefer static ...
2
votes
1answer
114 views

Is it still an antipattern if we log an exception message and throw a different exception?

Our webapplication is using an ExceptionMapper to map some exceptions to Response. We log the exception messages before throwing a new exception as follows: catch (SomeException ex) { ...
-6
votes
0answers
78 views

Recruitment Questions for the UK [on hold]

this is a bit cheeky of me but I've been referred here by a developer friend of mine. I Work for the UK government and we have always used external companies for our coding needs. We have decided it ...
-4
votes
1answer
126 views

Unexpected IndexOutOfBoundsException [on hold]

I was given a project in which there are lines like Object item = null; try { item = mShowsAdapter.get(0); } catch ...
13
votes
0answers
1k views

Can an abstract class be instantiated? [migrated]

abstract class A { public void disp() { System.out.print("Abstract"); } } public class B { public static void main(String args[]) { A object = new A(){ }; ...
1
vote
0answers
148 views

Why aren't Java Collections put in a dedicated package

Why do they just reside in java.util and not somewhere more specialized like java.collections or java.util.collections? It could contribute to mess up with different unrelated code. Couldn't it? Was ...
7
votes
5answers
388 views

When to use generics in interface design

I have some interfaces that I intend third-parties to implement in the future, and I provide a base implementation myself. I'll only be using a couple to show the example. Currently, they are defined ...
2
votes
0answers
48 views

Could Java import C++ classes from a library using JNA or JNI?

In past, I used JNI to access some winapi functions, however winapi is C and therefore just procedural. Now my plan is different and I need to know whether I'm going in the right direction. What I ...
1
vote
0answers
50 views

Decoupled architecture in Android

I am building an app for Android that will have multiple data sources depending on who is using it. N-tier architecture with a repository pattern seems like the right way to go about this but I am ...
1
vote
1answer
115 views

How does Java's Scanner (System.in) input's buffering actually work?

Over the last days, I've being reading questions as the one that follows: "Why is my input code not working?" I myself had a couple times problems getting the input working right... as far as good, i ...
-3
votes
0answers
136 views

Does a static class have to be nested? [on hold]

I have this problem: "Create a static class in java. This static class must be separate from the class that contain the main function." Is this possible? I thought java only supported nested static ...
-1
votes
0answers
30 views

how to organize android activities to be related? [on hold]

I'm working alone on android Project , and this is my first complete android project , and there are many activities and more parts are related for each activity , I write each part (which is related ...
7
votes
2answers
2k views

Why do we need an instance of the Scanner Class to get an Input on Java?

Java is object oriented, but, why do we need to create an object from the Scanner Class to get input? Couldn't next() methods, for example, just be Static? C looks to me pretty simpler as you just ...
3
votes
6answers
565 views

Design decisions while porting a non object-oriented C program to Java

Background: My boss made a comment on porting a C program that acts as some a simulator that communicates with a remote process through sockets to Java. He didn't assign it to me, or to anyone for ...
0
votes
0answers
63 views

Make a program deactivate after time [duplicate]

What I am referring to is a free trial. I would like to have a program that runs to a user who downloads it just like normal. However, I want the program to deactivate and become useless after a ...
-1
votes
0answers
28 views

Optimal Persistance Solution in Java [closed]

I've been working with Java and Spring for 2 years now. Before hand I work in PHP writing straight SQL, I would say I'm more SQL minded than ORM minded. I have struggled to really find a persistence ...
1
vote
0answers
37 views

Approaches to Modeling a Graph Database over the Google App Engine Datastore?

I want to model a graph database over the Google App Engine Datastore. I am currently working on creating a Link entity to model the concepts of link/edge/relationship to the graph of objects. I am ...
-3
votes
0answers
21 views

Mixing then printing arrays, but they all end up the same anyways? [migrated]

I'm making a sudoku game. I have an array (puzzle[][][]) containing nine other arrays (zone1[][]-zone9[][]), which each initially contain {{1,2,3},{4,5,6},{7,8,9}} (and they're assigned those values ...
0
votes
2answers
125 views

whats the relationship between integration testing, TDD and Agile methodology? [closed]

I recently attended an interview and was asked whats the relationship between integration testing, TDD and Agile methodology? I am still puzzled how to answer the question !!
3
votes
1answer
135 views

Should a new type be created though it only wraps a single field?

Say I have an interface Species that's defined as public interface Species { String getId(); String getDescription(); } The question is simply this: Should I create different classes to ...
7
votes
4answers
856 views

Should Objects with lots of fields be broken up? [duplicate]

When I have an Object that has lots of fields is it better to have them all as fields or try to find logical groupings as their own Objects and make those the fields? I guess it comes down to which ...
5
votes
4answers
214 views

Is Java package level scope useful?

I understand the idea of package scope, and at times have even thought I wanted it. However, every time I set down with a serious intent to try using it I discovered it did not fit the needs I ...
2
votes
3answers
93 views

Responsibility of the small business logic: in a class or in a method? [closed]

I have separated business logic to many small blocks. Each block can be coded in small number of lines. Where should I put the block code? [A] in a method, grouped in the class by some same feature ...
1
vote
3answers
130 views

How can I create an abstract parent class which uses data from an inherited class?

I'm getting my feet wet with Android app development and tying to find a good way to manage database interactions across multiple similar objects. My goal was to have a structure like: public ...
1
vote
0answers
58 views

Detecting surface faces of a huge 3D mesh/grid

I've written a module in my application that creates a mesh from existing coordinate and face data. The number of vertices in the mesh could easily exceed 10 million and the same goes for the faces. ...
1
vote
3answers
222 views

Would combining enums with static strings in java be sloppy?

Currently my team has a number of constants defined as static final strings. I want to be able to iterate over these strings as if they were an enum in one location, but everywhere else they are used ...
1
vote
1answer
88 views

What is the point of the dao layer? [closed]

With the current technologies which are pretty good (JPA, Hibernate, others), what is the point of the DAO layer? It's very rare for a project to switch its backend from one vendor to another, so it's ...
0
votes
1answer
34 views

How should one model an ExchangeService object (in ews-java-api) for sharing MS Exchange connections?

I am creating an application which uses ews-java-api to connect to an MS Exchange server. Once the connection is authenticated, the api dictates use of ExchangeService object for searching mailboxes, ...
-1
votes
0answers
19 views

Segmented file downloading potential gains vs excess overhead/problems

I'm writing a download manager, i want to get as much speed as i can from my downloads and I'm thinking about implementing segmented file downloading with conjunction to parallel download for each ...
2
votes
1answer
60 views

Android Pass Data between fragments

I have a question about passing data using bundle between fragments. I need to pass the URL from a Product object to the next fragment, so I don't know which is the best approach: to pass only the URL ...
0
votes
1answer
80 views

Collections.sort question

My question maybe related to this question - Encapsulating Internal Data Structure I have a class LCTile.java which contains a Coordinate.java class. Coordinate.java that contains latitude and ...
3
votes
2answers
185 views

Converting static utility class into singleton

In company where I work we have lots of "utility" classes, each has lots of code inside (thousands of lines), and they are all static. And one static methods call anothers. The problem here is that ...
-4
votes
1answer
148 views

Comparing the Java language to non-Java JVM languages [closed]

I was contemplating on the necessity of different non-Java languages coming up on the JVM. Apart from syntactic sugar and built-ins, does any of them actually exploit some corner of the JVM, which has ...
-1
votes
2answers
132 views

Modelling a parcel management application

Scenario/Context: I am working on an application which would find out the highest volume of parcel delivery based on the pin code of a particular area by reading a text file which has the list of ...
1
vote
1answer
99 views

Porting security from Java/.NET to PHP

This probably a rather naive question given my limited knowledge in the code I've been looking at, but I want to get my head around it before I start diving into writing actual code myself. I'm ...
4
votes
3answers
163 views

Track Bug fixes in code

I am working in a project in which at many point I need to change the code and fix the bug of the system but how can I inform other team members about this change? Usually I add single line comment to ...
-1
votes
0answers
105 views

What is abusing static? [duplicate]

Many people are always telling me not to abuse static in Java. What does that mean and why should it not be overused? The most recent case where I was told not to abuse static came when coding a ...
4
votes
1answer
91 views

How to load environment configuration

In Java the typical way of storing configuration is by using property files. So I have several such files, one for each environment type (dev, test, prod, ...). This configuration is needed in ...
0
votes
0answers
27 views

Android TranslateAnimation :: How to get the Speed of Mass Object

I'm currently having a project for making a springs-joint effect on android. And With two objects : A Mass Object A Springs (for hanging the mass object) And this link is my GIF animated of the ...
5
votes
4answers
283 views

Is using object of main class better than using static main method? [closed]

I have noticed in java programs at least, that people tend to prefer to start their programs by creating and instance of the class that contains the main method, and activating a non-static method ...
24
votes
7answers
2k views

Is there any practical way for a linked node structure to be immutable?

I decided to write a singly-linked list, and had the plan going in to make the internal linked node structure immutable. I ran into a snag though. Say I have the following linked nodes (from previous ...
1
vote
4answers
206 views

What are the differences between class variables and instance variables in Java? [closed]

I'm very new to Java and want to be difference between class variables and instance variables. For example: class Bicycle { int cadence = 0; int speed = 0; int gear = 1; } How are ...