[Solved] Syntax errors, but i see no errors

You can’t declare a try-catch in class level scope, just put it inside a method. Here is an example with a possible constructor that initializes your members: public SlickTTF(){ try{ awtFont = Font.createFont(Font.TRUETYPE_FONT, fontFile); awtFont = awtFont.deriveFont(20f); font = new TrueTypeFont(awtFont, true); }catch(Exception e){} } Now you can create an SlickTTF object as SlickTTF example … Read more

[Solved] showing error in java

I’m unsure whether I’m helping you or giving you a load of new problems and unanswered questions. The following will store the count of times the class Founder has been constructed in a file called useCount.txt in the program’s working directory (probably the root binary directory, where your .class files are stored). Next time you … Read more

[Solved] Default implementation for hashCode() and equals() for record vs class in Java

In a nutshell the difference is simple: the default implementation of equals() and hashCode() for java.lang.Object will never consider two objects as equal unless they are the same object (i.e. it’s “object identity”, i.e. x == y). the default implementation of equals() and hashCode() for records will consider all components (or fields) and compare them … Read more

[Solved] I am trying to build a simple calculator [closed]

You could keep track of what your first number is, and check if it is zero, then do nothing. if(newValue == true) disp.setText(“0”); else { if (!firstNumber.equals(“0”) disp.setText(disp.getText().toString() + “0”); newValue = false; } solved I am trying to build a simple calculator [closed]

[Solved] convert java code with RSA to c#

X509EncodedKeySpec is the SubjectPublicKey part of a certificate. So you probably need to decode this structure. You could look at BouncyCastle for C# and check out Org.BouncyCastle.Asn1.X509.SubjectPublicKeyInfo.GetInstance(byte[]) 1 solved convert java code with RSA to c#

[Solved] How to switch two numbered arrays in Java

Here is one solution with a reverseOrder method in a Collections class in java import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class test { public static void main(String[] args) { List<List<Integer>> numlist = new ArrayList<List<Integer>>(); List<Integer> somelist = new ArrayList<Integer>(); somelist.add(5); somelist.add(6); Integer[] aa = new Integer[somelist.size()]; Arrays.sort(somelist.toArray(aa), Collections.reverseOrder()); somelist.clear(); for(int i =0;i<aa.length;i++) … Read more

[Solved] Searching Duplicate String Complexity

You are making your code way too complicated, use a HashSet<String>, which will guarantee uniqueness and will return whether the element was already in the set. public class DuplicateEle { public static void main(String args[]) { Set<String> seen = new HashSet<>(); String[] arr = { “hello”, “hi”, “hello”, “howru” }; for (String word : arr) … Read more