How to solve Cannot invoke “String.compareTo(String)” because “[]” is null?

import java.util.Scanner; public class Search { static Scanner scanner = new Scanner(System.in); static Scanner kb = new Scanner(System.in); static Scanner kb2 = new Scanner(System.in); …

Javers – comparison String, Collection and Boolean with defined rules

I have 2 classes: @Data @Builder public class Boss { private String name; private List subordinates; } @Data @Builder public class Employee { private String …

Representation of an array as a polynomial

What this method should do is take an array of doubles and convert them into a polynomial, for example, if the array is given was [2.0, 3.0, -2.0] the method’s output would be 2.0x^2 + 3.0x^1 – 2.0. …

Recursively getting string user input with Scanner class in java

So, I want to receive input from the user, check if they used alphabetical values and then check if it is too long. If too long, I want to start again from the top (checking if alphabetical) by …

Why is it giving me an error when i’m calling it from inside the ‘student class?

*I have to Create a class called student but I’m getting an error and I didn’t know how to complete the code, but what I did is: public class Student { String name; private int age; private int grade;…

How would I get only the end result printed while also fixing the runtime error

I’m pretty new when it comes to coding in java (or coding in general), and I want the code below to print out only the end result (3), but it prints everything beforehand too, then once it reaches the …

Leetcode: Add Binary (Java) How can it perform addition between one char and one int?

class Solution { public String addBinary(String a, String b) { int len1 = a.length() – 1; int len2 = b.length() – 1; int carry = 0; StringBuilder …

Sort List of Strings arrays in Java

I’m trying to make a program that consists of an array of Strings . now I need to sort them in order ‘PJ’, ‘GHS’, ‘FJ’, ‘PAS’ and date. input : listOfStringArrays.add(new String[] { “200608&…

How to append in String Builder in java? [closed]

Suppose I have sentence in String X. How can I split each word in sentence and add a span tag for each word with class word and if the word matches with String y add class word selected? Both X and y …

How can I split a string without knowing the split characters a-priori?

For my project I have to read various input graphs. Unfortunately, the input edges have not the same format. Some of them are comma-separated, others are tab-separated, etc. For example: File 1: 123,…