r/learnjava • • Jun 13 '22

Java User Interface Frameworks

0 Upvotes

At my university, we have worked with JavaFX which is quite dated as a UI framework for Java, but somehow manages to still be good enough for the simple applications we’ve been building.

I wanna however, move to a more viable framework, but I have no idea what I could use to build a UI in Java other than Swing (which tbh, is no different from JavaFX).

What frameworks are out there that I could use to build a UI? Are there any good resources you know? Any tip is appreciated


r/learnjava • • Feb 24 '18

Graphics

0 Upvotes

Can someone teach me please? I really wanna learn graphics on Java and I already know the basis...


r/learnjava • • Feb 09 '17

Exception Handling question regarding "throws" [Will gild]

0 Upvotes

Let me get this straight.

If I have code that may throw an exception, I enclose this code in a throw block right?

Then, to deal with the exception I have to proceed with catch blocks.

Suppose I identified the type of exception that may occur and I create an exception block for it. I've successfully handled the exception then.

Why is the THROWS needed?

When creating a method, it is said that you need to specify the type of exception that will occur if the exception is checked. How does Java determine if an exception is going to occur during compile time, and if such an exception checked and not unchecked, or does it not determine that and simply halt the program when an checked exception that is not accounted for occurs?

I'm guessing if I don't specify that, say the method Circle(double radius) may throw a IllegalArgumentException and a negative raidus was entered the program would terminate right and not be able to proceed or be dealt with? In this case I specify the specific exception because that exception is checked?

If I specify that the exception is checked, why is it said that Java needs to propogate throw a check stack to see which exception occurred matches the exception in the callstack when I already told it in this instance?

I will GILD whoever helps me out and explains everything in details. I really mean it, thanks.


r/learnjava • • Dec 08 '17

Calling methods of a different class query

0 Upvotes

Hi guys.

Say I have a method in class A.

I then wish to call the method from class A in public static void main(String[] args).

How would I do so?


r/learnjava • • Feb 11 '17

Hiearchies

0 Upvotes

I'm having lots of trouble with hiearchies and would really appreciate it if someone could maybe help me out on discord. just pm me your username


r/learnjava • • Sep 25 '20

Learn java the weird way

0 Upvotes

Hello guys

I have read so many articles,  tried to start learning but , none of them worked out, 

Lately I was thinking about learning java this way ,

Watching someone builds an app , and I ask questions while he's working,

An app that has almost all java chapters applied, or more than one app,

 What do you guys think?

Lovely


r/learnjava • • Oct 09 '20

Books for learning Java?

0 Upvotes

I know the basics of programming from school where I learned how to program with C, can you guys recommend any books for me to buy and learn from?
Thanks.


r/learnjava • • Jan 17 '14

sorry if this is everywhere but i cant find anything. but is there anything actually usefull on android market or a good mobile website that i can look at and learn a bit more when im at work or just out and about

0 Upvotes

thank you


r/learnjava • • Oct 11 '16

PracticeIt CS courses from Washington Uni - Timing out when using Scanner functionality

0 Upvotes

Has anyone taken the java courses through PracticeIt? It's been a lot of fun and can be challenging.. However, I've noticed when I'm solving a lesson that requires using a Scanner object, the answers always fail because of a "*** TIMEOUT (infinite loop?)" error. Consider the following problem:

Write code to read an integer from the user, then print that number multiplied by 2. You may assume that the user types a valid integer. A sample run of the code would produce the following:

Type an integer: 4 4 times 2 = 8

        Scanner scanner = new Scanner(System.in);
        int val = 0;

        System.out.print("Type an integer:");
        while (scanner.hasNext()){

            val = scanner.nextInt();
        }

        System.out.println(String.format("%s times 2 = %s", val, (val*2)));

I know that the code works as is but the site times out when it tries to compile/run. Am I not terminating it correctly perhaps? I can't exactly contact the admin since I'm not a student. Any help is appreciated, as I can't finish several exercises because of this.


r/learnjava • • Feb 01 '24

Trying to learn Web Dev Basics for preparing in CRUD Java Web apps

0 Upvotes

Hello, recently I'm learning html and css, and before I move to javascript, I want to practice more in terms of creating website just using HTML and CSS. And sometimes I can managed to recreate the design and layout of a small part of a website without looking to the source code, and it looks very similar. However my code structure, class names, or specific CSS properties are differ from the original source but I still produce the desired visual outcome of the website. Is that fine ?


r/learnjava • • Nov 01 '23

Codegym or Code academy(subscription) for learninhg java.

0 Upvotes

I want to learn java from basic to pro level.Now I am confuced what will be the best for me for learning java and apply for a job. It will be very helpfull if anyone suggest me what to do?


r/learnjava • • Dec 28 '21

Is it still worth it to learn how to code a backend in Java with frameworks if it's faster to use a backend generator?

0 Upvotes

eg. duomly backend generator: https://www.backendgenerator.com/


r/learnjava • • Jan 28 '19

New guy here.

0 Upvotes

Hey, im quite new in Java and studying it at uni + youtube videos, i get some excercises but are there some extra good sites for excercises levels from beginner to hard (maybe these hard should include java fx and maybe android studio excercises) thanks in advance

Second thing is, since license is now required to publish apps and programs in java, is it worth to be studying it in 2019 or do you have some rising language tjat you think is more useful to learn in 2019?

Thanks for answers and sorry for bad english


r/learnjava • • Oct 05 '19

Quadratic Formula Practice program plz help

0 Upvotes

<!DOCTYPE html>

<html> <head> <meta charset="UTF-8"> <title>Quadratic Equation Practice</title> <style> </style> <script> let answer1 = 0; let correctNum = 0; let incorrectNum = 0;

function validate() {
a = document.forms["form1"]["a"].value;
b = document.forms["form1"]["b"].value;
c = document.forms["form1"]["c"].value;
if (a == 0) {
outputText = "Sorry, <em>a</em> cannot equal zero.";
} else if (isNaN(a)) {
outputText = "Sorry, <em>a</em> needs to be a number.";
} else if (isNaN(b)) {
outputText = "Sorry, <em>b</em> needs to be a number.";
} else if (isNaN(c)) {
outputText = "Sorry, <em>c</em> needs to be a number.";
}

function setup(){
resetEquation1();
}
function resetEquation1() {
let a = Math.floor(Math.random() * 10);
let b = Math.floor(Math.random() * 10);
let c = Math.floor(Math.random() * 10);
answer1 = (-b - Math.sqrt (Math.pow(b, 2) - 4 * a * c)) / (2 * a);
answer2 = (-b + Math.sqrt (Math.pow(b, 2) - 4 * a * c)) / (2 * a);
document.getElementById("eq1").innerHTML = "What is (-b + Math.sqrt (Math.pow(b, 2) - 4 * a * c)) / (2 * a)";

}
</script>

<p align="center">Use the Quadratic Equation to solve for a, b, and c. (Remeber the form <strong>ax\&#x00B2; + bx + c = 0</strong>)</p>

<br> <div id="submit-area"> <p align="center">Correct Answers: <span id="correct">0</span></p> </div>

<div id="submit-area"> <p align="center">Incorrect Answers: <span id="incorrect">0</span></p> </div>

</div> </head> <form align="center" name="form1" action="javascript:validate()"> a: <input type="text" name="a" size="4" required> b: <input type="text" name="b" size="4" required> c: <input type="text" name="c" size="4" required> <input type="submit"> </form> <p id="output_text"> </p> </html>


r/learnjava • • May 15 '19

How do I hit the requirements for this assignment for this prime number program?

0 Upvotes

Program: Create a program that finds all the prime numbers up to 500.

other requirements: https://pastebin.com/QT8AZNB5

Now, I did the program in the simplest (probably not the best) way I could, ignoring the specific requirements so i could understand the logic of it, and here's what I ended up with: https://pastebin.com/Kk1C8xa7

This program was simple enough that I could do it all in main, yet I'm supposed to incorporate modules, multiple files, classes, and a printable interface. How do I do that for a program that works just fine being entirely in Main? I mean the only class I can think of is pretty much to copy and paste the program, slap it into a class, and call the class methods in Main, but that seems so unnecessary. Also don't get how an interface could be beneficial here.

Any help?


r/learnjava • • Apr 17 '18

Good sources for learning

0 Upvotes

Hi guys, in the UK, anyone have any suggestions for the best site/course/material to learn Java. Paid or otherwise, I would probably be willing to dump 20 quid on it.

I have tasked myself with learning Java this year, do you think it is achievable?


r/learnjava • • May 20 '21

I'm not sure how to code this. Can somebody help me in anyway please?

0 Upvotes

So I got a java project but my lecturer doesn't explain anything. He just gave it and I'm really struggling on what to do. Can anybody tell me please?

Every vehicle has a maximum value, in kilograms, that can be loaded unto the vehicle. You must write a small application in JAVA that can assist a builder to determine if the goods he wants to buy weighs less than load capacity of his truck. Your program must:-

  1. Read the load capacity of the vehicle as input.

  2. Read the name and weight of three items as input.

  3. Calculate the total weight for the items.

  4. Display all items and the weight.

  5. Display the total weight for all items.

  6. If the total weight of the items is less than the load capacity of the vehicle, display the available weight capacity of the truck.

  7. If the total weight of the items is greater than the load capacity of the vehicle, display the value that is more than the load capacity of the vehicle.

Remember that all output must be user-friendly.


r/learnjava • • Nov 24 '19

Suggestions?

0 Upvotes

I want to learn java but I can't find any free and good videos.


r/learnjava • • Jun 18 '24

Learning java with GitHub CoPilot.

0 Upvotes

I am a beginner/intermediate java programmer at a community college. I am in a really crappy online class and am watching tons of tutorials. I have read articles watched videos and even done some remote online tutoring. I think I am in a bit over my head but I have been using CoPilot as a tool to learn!

  • First off let me say I am blown away with CoPilot's accuracy and coherency compared to Chat GPT.

  • I have been asking CoPilot to explain an error, method, or concept WITHOUT providing solutions and it has been the most consistent effective tool for rapid feed back on problems. It has even taught me some concepts my text book failed to explain well such as the difference between wrapper classes and primitive variables.

  • I started to learn to program in 2012 when i was about 13 and stopped after a couple years. Picked it back up recently as I want to work in the game Dev field. I wish this technology existed when I was first learning but I'm so glad it does now!

  • have any of you used CoPilot or similar applications to learn? Curious to hear your experiences/opinions on using AI this way.

  • lastly I know AI and LLMs aren't perfect at this kind of stuff but I am still blown away by the quality I am getting.


r/learnjava • • Jun 09 '24

I already have a background in PHP and I know the basics of Java

0 Upvotes

What do I need to learn to get a decent job with java web backend?


r/learnjava • • Mar 11 '24

What is the difference between import java.util.concurrent.ThreadLocalRandom; and import java.util.Random;

0 Upvotes

I am just curious what is the difference between the two as I am fairly new to using java.


r/learnjava • • Mar 20 '21

Stumbled across this and wondering its functionality?

0 Upvotes

package event.horizon.time.logging.json;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.ServerErrorException;
import javax.ws.rs.core.Response.Status;
import org.jboss.logging.Logger;
u/Path("/logging-json")
public class LoggingJsonResource {
private static final Logger LOG = Logger.getLogger(LoggingJsonResource.class);
private static final int SPEED_OF_SOUND_IN_METER_PER_SECOND = 343;
private final AtomicInteger speed = new AtomicInteger(0);
private final Random random = new Random();
public LoggingJsonResource() {
}

u/GET
u/Path("faster")
u/Produces({"text/plain"})
public String faster() {
int s = this.speed.addAndGet(this.random.nextInt(200));
if (s > 343) {
throw new ServerErrorException("\ud83d\udca5 SONIC BOOOOOM!!!", Status.SERVICE_UNAVAILABLE);
} else {
String message = String.format("Your jet aircraft speed is %s m/s.", s);
LOG.info(message);
return message + " Watch the logs...";
}
}
}


r/learnjava • • Feb 13 '21

String comparison - would any of these evaluate to true?

0 Upvotes

This is a slide from my course: https://i.imgur.com/LxGBpPP.jpg

String s1 = new String ("test");
String s2 = "test";
String s3 = s1;

Then they ask how would these evaluate?

s1==s2
s1==s3
s2==s3

I am guessing (but really not sure) that these would all evaluate to false? I suppose because they are all references to different objects, or something like that? I could do with checking, because teach doesn't appear to have given us the answer. TIA.


r/learnjava • • Feb 27 '21

Netbeans with TMC 1.4.0

0 Upvotes

After browsing around for a bit I saw a lot of good thing said about the java mooc fl course.
Course starts with setting up Netbeans with TMC and I am having an error at boot every time.

The error is:
Communication with server failed! Please check your internet connection and try again.
Try opening a browser and see if you can load any pages.

I'm definitely connected to the internet so I checked if any proxy settings were enabled in the program, they were set to system preferences. I turned it to No proxy just in case rebooted but still get the error.

Any idea how to debug this?