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.
0
votes
0answers
33 views
How to use composition in Java [duplicate]
So I've been recently trying to use composition in Java having just learnt about it, but I can't quite get my head around what its doing differently to inheritance.
So imagine this example. I'm ...
4
votes
3answers
255 views
Why should I use “functional operations” instead of a for loop?
for (Canvas canvas : list) {
}
NetBeans suggests me to use "functional operations":
list.stream().forEach((canvas) -> {
});
But why is this preferred? If anything, it is ...
-3
votes
0answers
40 views
Benefits of using javax.json over Jackson [on hold]
javax.json (JSR 353) is supposedly the standard way of reading and writing JSON. I like standards but I fail to see what are the benefits of using it instead of, for example, Jackson.
Automatic data ...
-5
votes
0answers
15 views
Can't store the input in an array location [on hold]
My aim is to define a number of "records" and then input the records as Strings and store them in the array sequentially.
However, the Exception in thread ...
-4
votes
0answers
32 views
What studies have beed done on balancing speed versus quality in agile, java development? [on hold]
I was recently in some technical interviews in an agile, java shop. The one theme that was recurring was this question: how do you balance speed versus quality? This made me very curious as I've ...
-4
votes
0answers
31 views
Where do I start? I want to automate some redundant office tasks [on hold]
I am not sure where I start or if I am asking the "right" question. I would like to create a program to open a website, select a link, enter form data, select a link and when the report is generated ...
0
votes
0answers
49 views
How to implement IPC in a java process [on hold]
I would like to implement a simple cli to "ping" some running jars and check their status, run some commands and stuff like that.
I was thinking to use Spark (http://sparkjava.com/) and implement ...
0
votes
1answer
49 views
Under the hood of Java application servers resources
We are used to Node.js / Python / Insert X.
Moving to a Java EE stack, it seems to me like all of the resources are 'press this button', 'do that' without any actual architectural explanation.
For ...
-5
votes
1answer
37 views
Restful API Using HATEOAS [on hold]
What are best practices for designing an API using HATEOAS that provides discover-able content via links without having to publish URI documentation?
Clients will access the root location and be ...
3
votes
1answer
111 views
Design Patterns when Class Needs External Awareness
When I was first taught Object Oriented principles, it was drilled into me that when using objects in a "hasA" relationship (or any similar situations where a helper object encapsulates a discrete ...
-4
votes
0answers
48 views
Spring-boot and maven multiple modules [on hold]
I'm trying to figure out, does it have any sense to split spring boot app, that have backend in java and frontend in html,angular and js into two maven modules, one woudl be *.jar (backend) and one ...
0
votes
0answers
41 views
What are situations to use public variables instead of getter/setter methods? [duplicate]
I was reading a bit about Servlets and JavaBeans and encountered for example this example from http://stackoverflow.com/questions/1727603/places-where-javabeans-are-used:
public class User implements ...
0
votes
0answers
59 views
Java Singleton's unknown behavior with Android Action Intents [on hold]
I have the following Java singleton defined for managing tokens in my Android application. I am initializing it at my starter activity.
// Singleton class for managing token
// Enforces modularity, ...
0
votes
1answer
57 views
Is this the correct way to think about the client/server socket relationship?
I'm designing a distributed application, very basic for now. The idea is that once the application is active on all machines (about 5 vms), you can initiate a grep on all log files from all machines ...
3
votes
2answers
218 views
Throwing an exception if some property is not present in a properties file
it's not a big programming problem, but I'm curious if it should be done better. So I have a config file which I'm reading via java.util.Properties class. When property is not present in a file ...
1
vote
1answer
67 views
Thread.State BLOCKED vs WAITING
What is difference between the BLOCKED and the WAITING states of a thread.
As per JAVA code comments
/**
* Thread state for a thread blocked waiting for a monitor lock.
* A thread in ...
0
votes
0answers
13 views
Spring pass-through authentication mechanism
I want to implement a "pass-through" authentication system using Java and Spring.
I want to create a service that will be transferring all incoming http requests to a different host/port where ...
-4
votes
0answers
34 views
Problem with methods in printing stars inJava [closed]
I am trying to create a program in Java that print stars by calling a method. I don't understand why it isn't working. Eclipse show no error and no output. Thanks!
public class methodAndParameters {
...
0
votes
1answer
101 views
How to update ui lively without refreshing page
I am doing a web application using struts2 framework. After user login, I show a dashboard about the current status of the user. To show the Dashboard UI(JSP), I used to get the information from the ...
3
votes
1answer
57 views
CharSequence to represent a named object
I always followed the opinion to not abuse interfaces in case of decomposition.
Usually I only implement them if I am absolutely sure to have a "is-a"-relation and avoid implementing them if there is ...
-4
votes
0answers
17 views
java error on processing [closed]
my host:
hardware:pcduinio (as Raspberry B)
ubuntu 12.04 arm-jdk 7 oracle-java
when Run processing example:
Libraries->video->GettingStartedCapture.pde
//******************
import ...
-6
votes
0answers
34 views
Java can read image and convert into it's pixel value but it can do reverse? [closed]
Is there an java program to convert the RGB value to a image?
0
votes
2answers
23 views
Spring StoredProcedure Inject declared parameters or not?
At work one of my colleague asked to me to change the way a Spring StoredProcedure subclass class was initialised from injecting the parameters with Dependency Injection mechanism (Constructor ...
-6
votes
0answers
24 views
What are the necessaries and basics that should be learned to be able to write an android app or develope it? [closed]
Am actually a beginner and am intersted in developing apps for android; i need to know what to do as a start ? I want to be able to develope then make apps with my own ..i want a brief explanation and ...
2
votes
1answer
53 views
Create a globally visible method for an API
I'm trying to create a Java API that I will use in other projects.
I understand that if I create new classes I can make objects in the other projects that have those classes. But what I want right ...
5
votes
1answer
69 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
102 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 ...
0
votes
0answers
12 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
4answers
217 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 ...
2
votes
1answer
144 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) {
...
-4
votes
1answer
132 views
Unexpected IndexOutOfBoundsException [closed]
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(){ };
...
4
votes
1answer
235 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 ...
8
votes
5answers
459 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
2answers
209 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
57 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 ...
0
votes
1answer
120 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 ...
9
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
578 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
vote
0answers
43 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 ...
3
votes
1answer
137 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
873 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
220 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 ...
1
vote
3answers
131 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
64 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
225 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 ...
0
votes
1answer
59 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, ...
-2
votes
0answers
26 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 ...