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
7 views
Should an object be able to represent itself across domains?
I'm working on a networked game. I have tried to design the various components (client, server, engine) to only about things within their domain. For example, the server should only be concerned with ...
-4
votes
0answers
25 views
How to continue with script even if NoSuchElement exception is thrown?
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
driver.findElement(By.id("ww")).click();
...
0
votes
0answers
17 views
Eventing solutions for java legacy applications too old for real JMS queue/topic eventing?
What are some architectural solutions that can mimic eventing for systems (Java) that are too old to implement eventing solutions, such as conventional Queue/Topic based JMS messaging?
I have a ...
0
votes
1answer
56 views
Design Pattern for Object Updates
I have a "Product" class that has some ID, and multiple other fields, and a function updateProduct(id, Product update). The intention is that "update" only contains the changed information - other ...
-3
votes
1answer
68 views
Convert Java code checker into analyser
I have made a application on Java which is check the code of Java, PHP, JavaScript and tell the errors line and what's the error but my boss want me to convert it into code analyser which can tell ...
-3
votes
1answer
94 views
Using System.out.println() with loops and arrays [on hold]
Is there anyway I can create a loop for System.out.println("...") and reading in the values? For example I wish to do this:
System.out.println("Input the Executive's name: ");
String eName = ...
-5
votes
0answers
55 views
How to add entries to an ArrayList in another class?
I'm trying to create a list of Strings that user has saved as favourites. The Favourites are displayed in a class separate to the MainActivity in their own list, but the user is supposed to mark it as ...
-2
votes
0answers
33 views
Database structure for an Android chat application
I have a structuring or rather designing problem. I am developing an Android chat application and I need to know if anyone has an idea on how the database should be structured to allow group and ...
-1
votes
0answers
44 views
How should I approach learning Java EE in rapid mode in the following scenario
I am a client side Java developer and my day passes by coding 80% of the time on Android. Recently I changed my job and joined a big shot company here. However I was given additional roles and asked ...
-1
votes
0answers
33 views
please help me regarding backward compatibility of java1.8 with security features
I'm upgrading my application to java1.8 - reason is some of our customers have started using 2048 bit encrypted certificate. But I have two concerns , please help me with these queries:
For incoming ...
0
votes
0answers
37 views
How to save the differences between objects which are the result of random changes?
I keep a state object of the following form:
class State {
int num1, num2;
List<String> strings;
MyObject myObject; // A class I wrote
// etc.
}
The state changes many times ...
-2
votes
0answers
18 views
Monitoring remote server in java
My goal is to create a spring mvc based application that shows the states of a remote server (ram,cpu usage ...) in charts. Is there any java API that makes this doable ? (an API with which i can ...
0
votes
0answers
34 views
Scrabble generating vowels and consonants [on hold]
I want to generate randomly 3 vowels and 4 consonants Here's my code
public static void main(String[] args) {
String consonantes = "BCDFGHJKLMNPQRSTWXYZ";
String vocales = "AEIOU";
...
4
votes
2answers
124 views
Question about Java's proposed value types
I'm reading the Project Valhalla proposal to add value types to Java. It's arguing for explicit value types because the compiler can't automatically move allocations from the heap to the stack very ...
2
votes
4answers
155 views
Should I initialize a List when declaring it or should I use a static block?
Could anyone explain which one of the two snippets below would be best practice for initializing a static final List?
Initialize when declaring:
public class Sample {
private static final ...
0
votes
0answers
11 views
Visibility into Tomcat & WebApplication ClassPath loads
I am not sure if this is a thing that can be done, or if it is way to dependent on my development environment: Is there a quick way to see which applications are loading in which jar files for class ...
-1
votes
2answers
176 views
Why is referencing arrays, instead of copying them, bad? [on hold]
Is it because the advantage of copying a array into another array is that you can have the data added onto the array itself, rather than just referencing a particular memory location?
-3
votes
0answers
35 views
Scanner class question [on hold]
This program asks the user for a number of items to enter into an array. The array computes the average, then determines how many of the items entered into the array are over this average.
import ...
-3
votes
0answers
49 views
Implement OPTIONS in to build mini HTTP client [on hold]
I have a question about method OPTION.
I have this .java file:
import java.net.*;
import java.io.*;
public class clientetcp {
public static void main(String argv[]) {
if (argv.length == 0) {
...
2
votes
2answers
62 views
Dealing with runtime exceptions when reading from file
Let's say I read a bunch of numbers from a text file. Each line is initially a string, I need to parse it to an integer. This is where the first exception might happen - NumberFormatException thrown ...
4
votes
1answer
82 views
Three classes and get methods
class A{
private List<T> list;
public int getListSize(){
return list.size();
}
}
class B{
private A objectA;
public int getSizeOfListInA{
return ...
1
vote
1answer
110 views
Supporting Multiple Java Versions in OSS Libraries
I am in the process of standing up my first OSS Java lib (GitHub/Maven) that an open source hardware community will be making fair/moderate use of.
I am writing this library with Java 8 and managing ...
2
votes
4answers
314 views
Why isn't there a primitive “complex number” type in Java?
Does anyone know why something like http://www.ipd.uka.de/JavaParty/cj/#Down was never completed and integrated into mainline java?
This seems like a no-brainer... I realize the java gawds dont want ...
0
votes
0answers
25 views
Good practice for layered application with internationalization
I'm designing a new application in JSE which I want to internationalize.
I've never done such an application. I'm looking for the best practices about the internationalization. The application while ...
0
votes
0answers
52 views
Design of thread pool reuse with Executors.newFixedThreadPool in Java [migrated]
In my application I have a code, which should run every hour on a new items and execute some expensive operation with multi threading.
Code fragment:
int i = 1;
//noinspection InfiniteLoopStatement
...
-3
votes
0answers
35 views
How does Java ninja framework's database migration works? [on hold]
There's three things in database migration.
DatabaseModelsVx__.sql files
apparently ninja database migration system (as i know: flyway) connects these three things automatically. but I can not ...
5
votes
1answer
60 views
Storing pairs in a map
If I have a Pair class like this:
class Pair<K, L>{
public final K a;
public final L b;
public Pair(K obj1, L obj2){this.a = obj1; this.b = obj2;}
//...
}
I want to associate a ...
1
vote
1answer
53 views
How to detect network interruptions
I want to write a kind of "diagnostic function" which is able to detect when a TCP/IP based network is interrupted.
I would like to connect two endpoints and detect when an established connection ...
2
votes
3answers
120 views
What is the least bad way of knowing the type of a key from Json file
in our app we have a Json file that contains several properties used for menu configuration. One of the keys should tell us if a menu item should be displayed. The thing is that the value for this ...
0
votes
2answers
87 views
Accessing C methods from class A
class A {
B bObject;
}
class B {
private List<SomeType> list;
public List getList() {return list;}
public void foo(int i) {
list.get(i).someTypeMethod(); // 2 dots
}
...
2
votes
1answer
75 views
Constructor Injection vs Field Injection
I know this topic has been discussed a lot already so I don't want to get into which one is the "best way".
I have been using field injection for a couple of years now but recently I discovered that ...
-1
votes
2answers
77 views
Which is better either creating two objects for two threads or one object for two threads?
In the below program, I'm calling method1() of SampleClass from two threads. So, basically I have created two objects for each thread and called the method1(). I have also seen the scenario of ...
-2
votes
3answers
167 views
Is it possible to have private or protected objects in Java? Or are all objects considered public?
Is it possible to have private objects? For example, when you instantiate an object (classType object1 = new classType()), can that be private or protected or is it always public?
0
votes
1answer
60 views
How do you write super() in the UML format?Is it correct to write super(parameter: type): return type in the UML methods section?
Suppose you write a subclass that extends to a certain class and in that subclass, you use the super() method for your constructor.
Would you write "super(parameter: type): return type" in the UML?
-1
votes
1answer
52 views
Enable matching of character sequence made up of regex control character
Java Pattern provides flags that enables you match regex control characters. Passing Pattern.LITERAL or 16 as second argument will match any Unicode char, but not if you use a word bound with the ...
0
votes
1answer
86 views
What is a good approach to get a detailed system design from an existing system?
I will be working on a system which will be ported over from Java to .Net. It is a pretty big system. I don't have any specifics about how the system is designed, no documentation, nothing.
You know ...
2
votes
2answers
154 views
Mutable objects - setters and getters
Is it a good practice to have a setter method of this kind? With primitive types, it's obviously fine, but when you have a setter for a field which holds a reference to mutable object, this might go ...
-1
votes
0answers
85 views
Writing clean and efficient recursive function [migrated]
How would you rewrite this function, to be as much readable as possible, while containing minimum lines and being not much slower:
public void reach(int index, int row, int column){
...
3
votes
2answers
157 views
How do people make libraries cross-platform?
How do people make libraries cross-platform (UNIX-systems and Android, sometimes even iOS)?
What do they use?
I'm asking this because I make libraries as a hobby and I'm curious.
5
votes
3answers
311 views
Best practices for using public, protected, private?
Is it fair to say that it is good practice to default everything to private up front when coding something?
And then only upgrade it to protected if a subclass needs it, or public if another class ...
1
vote
1answer
35 views
Better way to organize query methods in Android?
In my Android app I have a
SQLiteHelper class that extends SQLIteOpenHelper, and takes care of things like table-creation and upgrades.
SQLiteDatasource class that performs CRUD operations on the ...
-1
votes
0answers
18 views
CXF compatibility with Spring-WS
My company has web applications that use external web services; some are REST, some are SOAP. We're based on Apache/Tomcat, and use Spring (versions from 2.5 on).
We have a web service that is now ...
3
votes
1answer
78 views
Bounded Type Parameters
Ref: https://docs.oracle.com/javase/tutorial/java/generics/bounded.html,
We have the method: public <U extends Number> void inspect(U u)
Why can't this be: public void inspect(Number n) ?
It ...
-3
votes
2answers
58 views
class name for linked lists
I have a question about how to name a class in java. Could a class name be arbitrary or have to obey some rules? For example, I want to define linked lists in a class, does the class name have to be ...
-2
votes
0answers
74 views
Programming Logic Question (Allocating servers resources in a game) [on hold]
I'm currently working on a game in which you are able to run a DataCentre and customers will purchase different packages and then be assigned space on different servers which you have in each of your ...
2
votes
3answers
83 views
Calling a constructor from a parent class in a derived class
I'm trying to create a parent class with a constructor that takes a single int as a parameter. I also need to derive a child class that creates two instances of the parent class using a constructor ...
3
votes
2answers
189 views
Using MVC style, where is the best place to put SQL functionality?
I am wondering about best practices here.
MVC (Model - View - Controller) patterns involve separating components of your program that model the data, manipulate those models, and display those ...
0
votes
1answer
68 views
How to import driver details and Connection details without writing it manually or hard coding?
class ConnectionUtil{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(
...
5
votes
1answer
67 views
How can I plugin new JARs implementing an interface dynamically?
Quick background: I am working on developing an interface that will be implemented by myself and other developers. This interface will allow users to "plugin" new functional code into a system for ...
2
votes
3answers
146 views
designing classes for testability
I am writing a library for OVH api calls, and I am wondering how to make it friendly for unit tests.
I have a class APIClient. The constructor of this class initializes the object with all parameters, ...