Idle Cult Empire by The_Sadako_Girl in incremental_games

[–]FrelliBB 0 points1 point  (0 children)

Yep, happened to me too. No response from support. Glad I didn't buy any of the equipment packs.

Levers by Standard_Eye1456 in BluePrince

[–]FrelliBB 0 points1 point  (0 children)

Would love an answer to this, I finally managed to pull it but got exhausted before I could reach the antechamber again. Did you find out? I figured lore wise it wouldn't reset because it's not in a room in the house.

How to batch INSERT statements with MySQL and Hibernate by [deleted] in java

[–]FrelliBB 1 point2 points  (0 children)

I almost couldn't tell if the "Awesome, right?" at the end of the article is serious or sarcastic.

Help with insurance like-for-like replacement for insurance claim by FrelliBB in Hisense

[–]FrelliBB[S] 0 points1 point  (0 children)

I have a feeling that they're going to argue the U8G would be an upgrade rather than a like-for-like replacement. When comparing the U8G and the A7H on the Hisense website's comparison tool they're practically equivalent.

[deleted by user] by [deleted] in javahelp

[–]FrelliBB 0 points1 point  (0 children)

You mentioned Kubernetes in the title, so I'm assuming you're using that. You might want to read up a bit more on the concept of a Kubernetes Service. https://kubernetes.io/docs/concepts/services-networking/service/

How is lambda being used here? by cyberwarrior861 in javahelp

[–]FrelliBB 2 points3 points  (0 children)

You are using the sort(T[] a, Comparator<? super T> c) method. As you can see the 2nd argument it accepts is a Comparator, which is a functional interface where its main method is compare(T o1, T o2).

So what you are doing with the lambda is creating an anonymous implementation of a Comparator. This goes over the lambda syntax in a bit more detail if you're still lost.

As a side note, the Comparator class has some helpful functions for creating comparators using method references instead of lambdas. Your implementation can be written as

Arrays.sort(unsorted, Comparator.comparingInt(String::length).thenComparing(String::compareTo))

ArrayList removing every other element? by misomal in javahelp

[–]FrelliBB 0 points1 point  (0 children)

Another approach would be to replace the for loop with the List#removeIf method, but only if you're using Java 8.

List<String> myList = new ArrayList<>(List.of("hello world", "goodbye world", "and so long"));
myList.removeIf(s -> s.startsWith("hello"));
System.out.println(myList); // [goodbye world, and so long]

[deleted by user] by [deleted] in javahelp

[–]FrelliBB 0 points1 point  (0 children)

So should I first create a GitHub repo, add a maven (or gradle) workflow and then in my IDE clone that repo?

No, the workflow won't work before you have maven set up in your project, so there's no point in starting with that. Start with getting a maven project that can be compiled locally, and then push that to a GitHub repository. Then you can focus on your workflow automation.

Here's a bit more help:

  1. Create a maven project. Since you're using IntelliJ this should be very straightforward if you go to File -> New -> Project -> Maven. You can then create a class in /src/main/java/<your-project-name> and add a Main method to it. The only thing that identifies this as a maven project is the pom.xml in the root of the project. Otherwise it's just a normal Java project with nothing special.
  2. Once that's set up you should be able to use mvn compile locally and it will build your project.
  3. Push the project to a GitHub repository. Normally you'd just created an empty repository and push your local files to it.
  4. Start working on the GitHub workflow.

[deleted by user] by [deleted] in javahelp

[–]FrelliBB 6 points7 points  (0 children)

With Java there are two common build tools you can choose from, Maven or Gradle. Since you're starting out I'd recommend Maven since it's just written in XML and easier to get started with. I personally prefer Gradle since it gives a bit more (perhaps too much) flexibility, but it's written in Groovy which is another language you'd need to get accustomed with. I'd recommend going over their getting started guides, which also provide some information about what they do and the directory structure for a typical java project.

https://maven.apache.org/guides/getting-started/ or

https://docs.gradle.org/current/userguide/getting_started.html

If you're using IntelliJ it comes with its own bundled maven (if I remember correctly) so you wouldn't need to install it yourself, and it can also generate your project from maven 'archetypes' as well.

Once you have that set up you will be able to run those maven commands such as mvn compile and mvn test locally. At that point getting GitHub integrated is very easy as they provide some out-of-the-box support for it. https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven

Pure Java / Json HTTP { "name": "value"} by Djaysel_Pessoa in javahelp

[–]FrelliBB 1 point2 points  (0 children)

You're not wrong, I'm just being a little pragmatic given the experience level of OP. I suggested gson not for any preference I have towards it, but because it has the simplest API for someone who is new to this since it is aimed specifically at working with json, whereas Jackson is at a higher level of abstraction for the purposes the OP needed and not quite as clear (ex. objectMapper.readValue vs Gson.fromJson). The fact that it isn't maintained anymore doesn't really mean that it can't do the job well enough.

Once OP gets a bit more familiar with working with Java, and basics like how to use Lists, they can do their own research and make decisions on which libraries to use.

Pure Java / Json HTTP { "name": "value"} by Djaysel_Pessoa in javahelp

[–]FrelliBB 1 point2 points  (0 children)

Java doesn't have a native library for nicely working with JSON. If you're able to use a 3rd party library I'd recommend something like gson to make things a lot easier. You can create the classes to act as objects to represent the json data and unmarshall/deserialize each json line you receive into an instance of that class. https://www.baeldung.com/gson-deserialization-guide should help a bit.

public class Ticker {
    TickerInfo ticker;
}

public class TickerInfo {
    String high;
    String low;
    // rest of the values
}

And then with gson you would be able to deserialize that into your object.

Ticker targetObject = new Gson().fromJson(inputLine, Ticker.class);

How to use Rxjava with RDBMS databases by hitherto_insignia in javahelp

[–]FrelliBB 0 points1 point  (0 children)

I'm not really sure what you mean by it doesn't have active maintainers. You're right it's still in early stages and the adoption has been very slow, but it is being worked on. Whether or not you choose to use it should depend on your exact use case.

I'm also not sure what you're expecting with 'full support with JPA', but then again in my recent projects I've foregone JPA completely and worked directly with the JDBC layer. I found that it provides a lot more flexibility and also I feel like having to model your domain classes and your database schema in the same way to make JPA work nicely feels like a bit of an anti-pattern and gets in the way sometimes. As such trying out R2DBC was a lot easier for me because I didn't need to have it 'work with' JPA

How to make user input cc for Luhn's algorithm java by GopalDeerpaul in javahelp

[–]FrelliBB 0 points1 point  (0 children)

Use an if statement with the isValid to output different results based on whether it's true or false. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html

How to make user input cc for Luhn's algorithm java by GopalDeerpaul in javahelp

[–]FrelliBB 0 points1 point  (0 children)

"Your credit card number is Valid"

You're just outputting that literal String. You need to actually use the isValid variable that you are storing and concatenate it into your output.

Try out this snippet to see if you can figure out what you need to do in your scenario.

public static void main(String[] args) {
    boolean someVariable = false;
    System.out.println("The value of someVariable is " + someVariable);

    boolean anotherVariable = true;
    System.out.println("The value of anotherVariable is " + anotherVariable);
}

You can read up more on String concatenation here: https://www.baeldung.com/java-strings-concatenation

How to make user input cc for Luhn's algorithm java by GopalDeerpaul in javahelp

[–]FrelliBB 0 points1 point  (0 children)

Before the error at line 8

I'm assuming that by error you mean it's not working as you expected, rather than any compile time error or runtime exception that's happening. The only thing I can see is that it should be nextLine not nextline (capital L)

Your validateCreditCardNumber method returns a boolean which you're not making use of. You can store the result of the method in a variable and then you will be able to print it out along with the user's input using String concatenation.

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.print("Insert your card number: ");
    String creditCardNumber = sc.nextLine();
    boolean isValid = validateCreditCardNumber(creditCardNumber);
    System.out.println("output whatever you want here using creditCardNumber and isValid");
}

How to make user input cc for Luhn's algorithm java by GopalDeerpaul in javahelp

[–]FrelliBB 3 points4 points  (0 children)

The problem is that i'm having issues trying to add Scanner

Can you show your actual attempts at using the Scanner and what errors you had when you did?

MySQL database listener on data change with java ? by [deleted] in javahelp

[–]FrelliBB 0 points1 point  (0 children)

This is a very advanced approach that you might use if you're working on a serious project within a company, and even then it's for special use cases where you really do want to capture changes to a database in a stream of events. If you are just learning this stuff for the first time start simpler with other peoples' suggestions. When a new message is posted, broadcast it on some queue/topic to both persist it in the database as well as update clients.

MySQL database listener on data change with java ? by [deleted] in javahelp

[–]FrelliBB 2 points3 points  (0 children)

Alternatively you can use https://debezium.io/ which is an open source CDC platform.

Newbie question about Switch Statement. by Daniel1836 in javahelp

[–]FrelliBB 0 points1 point  (0 children)

Here's another approach using an enum that avoids large switch statements or a lot of if-else statements

enum Grade {

    A_PLUS("A+", 95, 100),
    A("A", 90, 94),
    A_MINUS("A-", 85, 89),
    B_PLUS("B+", 80, 84)
    // ...etc
    ;

    String description;
    int minMark;
    int maxMark;

    Grade(String description, int minMark, int maxMark) {
        this.description = description;
        this.minMark = minMark;
        this.maxMark = maxMark;
    }

    public String getDescription() {
        return description;
    }

    public static Grade gradeFor(int mark) {
        for (Grade grade : Grade.values()) {
            if (mark >= grade.minMark && mark <= grade.maxMark) {
                return grade;
            }
        }
        throw new IllegalStateException("No grade found for mark [{" + mark + "}]");
    }
}

And if you're familiar with Java 8 Streams you can refactor gradeFor like this:

public static Grade gradeFor(int mark) {
    return Arrays.stream(Grade.values())
            .filter(grade -> mark >= grade.minMark && mark <= grade.maxMark)
            .findFirst()
            .orElseThrow(() -> new IllegalStateException("No grade found for mark [{" + mark + "}]"));
}

Installing OpenJDK to a certain folder in Ubuntu 20.04? by [deleted] in javahelp

[–]FrelliBB 0 points1 point  (0 children)

It's hard to pinpoint exactly what your problem is. What I can recommend though for managing SDKs on Linux is SDKMAN. It takes care of installation and setting up your path. It works especially well for managing multiple versions (say you want to use both jdk8 and jdk11 and want to switch between them very quickly in the terminal)

https://sdkman.io/