493 Answered Questions for the topic Java

Java

05/10/19

Finding if Path2D self-intersects?

I need to find if Path2D intersects itself. For now, I do it by simply extracting an array of lines from path, and finding if any of these intersect. But it has O(n^2) complexity, and so it is very... more
Java

05/08/19

Computer Science

You have a secret integer in a certain range in your mind. Write an efficient guess procedure from computer to get the target. For example, if the target is in [0, 100], then your... more
Java

05/08/19

How to create a polygon in JTS when we have list of coordinate?

We can create a LineString using coordinates list like this: Geometry g1 = new GeometryFactory().createLineString(coordinates); How can we create a polygon using coordinates list? Thanks in... more
Java

05/08/19

Calculating the angle between two lines without having to calculate the slope? (Java)?

I have two Lines: L1 and L2. I want to calculate the angle between the two lines. L1 has points: `{(x1, y1), (x2, y2)}` and L2 has points: `{(x3, y3), (x4, y4)}`. How can I calculate the angle... more
Java

05/08/19

Computer Science

Write a program that takes website names as keyboard input until the user types the word "stop" (without quotes) and counts how many of the website names are commercial website names (i.e., end... more
Java

05/08/19

Java - Which accounting module is best to embed in my JAVA application?

I am developing a java application. I want to integrated some accounting module in my app. I don't want any feature-rich accounting module. I just want to maintain - salaries - expenses -... more
Java

05/07/19

How can I get the SQL of a PreparedStatement?

I have a general Java method with the following method signature: private static ResultSet runSQLResultSet(String sql, Object... queryParams) It opens a connection, builds a `PreparedStatement`... more
Java

05/06/19

Why doesn't Java allow overriding of static methods?

Why is it not possible to override static methods?If possible, please use an example.
Java

05/05/19

How to update a value, given a key in a java hashmap?

Suppose we have a `HashMap<String, Integer>` in Java. How do I update (increment) the integer value of the string key for each existence of the string I find? One could remove and reenter the... more
Java

05/05/19

Account Balance verification with Java and Hibernate HQL?

I have following properties in my current Account Balance object: long id; // Database ID Date date; // date when this balance object was created boolean... more
Java

05/05/19

Library for polynomial calculus in Java?

Are there any (preferably open source) library for Java that allows one to do calculus with polynomial e.g. addition, multiplying, dividing by constans etc. ? Also if it would be capable to... more
Java

05/02/19

3D Game Geometry?

I have a simple game that uses a 3D grid representation, something like: Blocks grid[10][10][10]; The person in the game is represented by a point and a sight vector: double x,y,z,... more
Java

05/02/19

Is a point inside regular hexagon?

I'm looking for advice on the best way to proceed. I'm trying to find whether a given point A:(a, b) is inside a regular hexagon, defined with center O:(x, y) and diameter of circumscribing circle.... more
Java

05/02/19

How to fill color on triangle?

I draw a triangle using line. How can I fill color on it? So far I can only color the line but not fill the color. public void paintComponent(Graphics g){ super.paintComponents(g); ... more
Java

04/30/19

What's the difference between getPath(), getAbsolutePath(), and getCanonicalPath() in Java?

What's the difference between `getPath()`, `getAbsolutePath()`, and `getCanonicalPath()` in Java? And when do I use each one?
Java

04/30/19

How do I split a string with any whitespace chars as delimiters?

What regex pattern would need I to pass to the `java.lang.String.split()` method to split a String into an Array of substrings using all whitespace characters (' ', '\ ', '\ ', etc.) as delimiters?

04/30/19

How to create our own plugins in adobe indesign?

I want to create my own plugin, Is there any tutorial available. I want to do it in java. Thanks in Advance.

04/29/19

Java: Date from unix timestamp?

I need to convert a unix timestamp to a date object. I tried this: java.util.Date time = new java.util.Date(timeStamp); Timestamp value is: `1280512800` The Date should be "2010/07/30 -... more
Java

04/29/19

How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

How can I tell if the JVM my application runs in is 32 bit or 64-bit? Specifically, what function or preference do I access to detect this within the program?
Java

04/29/19

Type List vs type ArrayList in Java?

(1) List<?> myList = new ArrayList<?>(); (2) ArrayList<?> myList = new ArrayList<?>(); I understand that with (1), implementations of the List interface can be swapped. It... more
Java

04/29/19

How do I find the inverse tangent of a line?

I've got a line (x1,y1) and (x2,y2). I'd like to use tan inverse to find the angle of that line, how would I do so in java? I'd like to see what angle the line makes in relation to x1,y1
Java

04/27/19

ArithmeticException: "Non-terminating decimal expansion; no exact representable decimal result"?

Why does the following code raise the exception shown below? BigDecimal a = new BigDecimal("1.6"); BigDecimal b = new BigDecimal("9.2"); a.divide(b) // results in the following exception:... more
Java

04/27/19

Convert list to array in Java?

How can I convert a `List` to an `Array` in Java? Check the code below: ArrayList<Tienda> tiendas; List<Tienda> tiendasList; tiendas = new ArrayList<Tienda>(); Resources res =... more
Java

04/27/19

Dynamic Programming and Knapsack Application?

Im studying dynamic programming and am looking to solve the following problem, which can be found here http://www.cs.berkeley.edu/~vazirani/algorithms/chap6.pdf: You are given a rectangular piece... more
Java

04/26/19

Any way to declare an array in-line?

Let's say I have a method m() that takes an array of Strings as an argument. Is there a way I can just declare this array in-line when I make the call? I.e. instead of: String[] strs = {"blah",... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.