java: inheritance

Java
What are some alternatives to inheritance?
2 years ago

Java JOptionPane

Java
I'm creating a Tic Tac Toe GUI based game in Java and am struggling with using 2D arrays with JOptionPane. So far I have been able to create the butto...
1 year ago

Java Serializable

Java
i have made a serialized class,like this ` class Example implements Serializable { transient byte i=2; transient byte j=3; Example(){Sys...
1 year ago

Java: InvocationTargetException

Java
I am dynamically creating classes in Java and trying to invoke methods in them, however, sometimes I get a java.lang.reflect.InvocationTargetException...
1 year ago

Java 8 and Java time

Java
I know the default Java library for Codename One is now Java 8 and I am also compiling locally with Java 8. I am trying to use the new java.time API...
1 year ago

Java String.toUpperCase()

Java
Just the other day I ran into a strange strange bug. I had a string of characters that I had to build. And as a delimiter the host system I was commun...
2 years ago

Java InstantiationException

Java
I made a class to implement an interface and was testing it using another class. This is the class that I created. public class MyWeaponI implement...
2 years ago

Java Constructors

Java
I am trying to learn how to specify class constructors in Java. I am starting to understand that they specify the types of instance variables of objec...
2 years ago

Java - ArrayIndexOutOfBoundsException

Java
I am working on a java program that generates random numbers and then puts them in an array. Then the program is supposed to go through the array, put...
2 years ago

Java Exceptions

Java
I am practicing for my java oracle certification test and found this in one of the oracle sample questions. I am not sure why the answer is A and need...
2 years ago

Java generics

Java
Is it possible to make a method that will take anything, including objects, Integers etc? I have a method checking the value if it is null and I was t...
1 year ago

Java BigDecimal.round()

Java
I am trying to round a BigDecimal value to the nearest 1000 using the below code BigDecimal oldValue = new BigDecimal("791232"); BigDecimal newValue...
1 year ago

Java: Skydiving

Java
Sorry for lack of details, I made a few edits. I've got a problem in my java class that I can't wrap my head around. I need to make a program that d...
1 year ago

java - Thread.sleep

Java
In the code and output below, t2 doesn't start until t1 finishes. Shouldn't they work parallel? Is Thread.sleep() affect whole process? public class ...
1 year ago

Java .class.getResourceAsStream()

Java
To the best of my knowledge, Class.getResourceAsStream() gets an InputStream directed at a file within the .jar file? If I'm wrong about this, please ...
1 year ago

Java: Graphics2D

Java
import java.awt.*; import javax.swing.*; import java.awt.event.*; public class SimpleGui3C implements ActionListener { JFrame frame; public static ...
2 years ago

Java Annotations

Java
What is the purpose of annotations in Java? I have this fuzzy idea of them as somewhere in between a comment and actual code. Do they affect the progr...
2 years ago

Java PropertyChangeListener

Java
I'm trying to figure out how to listen to a property change in another class. Below is my code: ClassWithProperty has the property I want to listen t...
1 year ago

java palindrome

Java
boolean checkPalindrome(String inputString) { int j=0; for(int i=0;i<inputString.length();i++) { j=inputString.length()-1; if(inputString.c...
1 year ago

Java almostIncreasingSequence

Java
Okay so i just started out on CodeFight, I got this question: After a couple of hours of trying to figure a way by myself to solve it i got it fully...
1 year ago