r/learnjava • • Nov 24 '22

Absolut beginner want to learn Java

1 Upvotes

Hey everybody Im new to programming,i want to switch my career from an accountant to Java developer and i have no experience in programming or coding I want to learn Java and i have some questions How long is gonna take me to learn Java? How much hours a day i need to learn it ?

Thank you


r/learnjava • • May 23 '21

Understanding the math behind this method

0 Upvotes

Hey guys. I ran across a cool method that returns the intersection point of two lines but I struggle to understand the logic and math behind this specific method:

` /**
* This method calculates the x and y coordinates of the intersection point the line and another given line.
*
* u/param other - the line with which the intersection point is calculated.
* u/return the intersection point between the two lines.
*/
public Point intersectionWith(Line other) {
Point firstPoint = this.start;
Point secondPoint = this.end;
Point thirdPoint = other.start;
Point fourthPoint = other.end;
double denominator = (fourthPoint.getY() - thirdPoint.getY()) * (secondPoint.getX() - firstPoint.getX())
- (fourthPoint.getX() - thirdPoint.getX()) * (secondPoint.getY() - firstPoint.getY());
if (denominator != 0.0) {
double firstPass = ((fourthPoint.getX() - thirdPoint.getX()) * (firstPoint.getY() - thirdPoint.getY())
- (fourthPoint.getY() - thirdPoint.getY()) * (firstPoint.getX() - thirdPoint.getX())) / denominator;
if (firstPass >= 0.0 && firstPass <= 1.0) {
double secondPass = ((secondPoint.getX() - firstPoint.getX()) * (firstPoint.getY() - thirdPoint.getY())
- (secondPoint.getY() - firstPoint.getY()) * (firstPoint.getX() - thirdPoint.getX()))
/ denominator;
if (secondPass >= 0.0 && secondPass <= 1.0) {
double x = firstPoint.getX() + firstPass * (secondPoint.getX() - firstPoint.getX());
double y = firstPoint.getY() + firstPass * (secondPoint.getY() - firstPoint.getY());
return new Point(x, y);
}
}
}
return null;
} `

can someone explain the logic behind this method? please


r/learnjava • • Nov 26 '19

Cannot run program "cmd"

1 Upvotes

Anyone knows how to fix this error in Netbeans. I got this error while running the program using java 8.


r/learnjava • • Aug 14 '25

Why are profiling tools so unknown even for 10+ years of experience folks?

1 Upvotes

I don't understand it. People just don't have any interest in how their app works? Isn't there any light of curiosity about the resources that are being used by their app and why?

If you go to jdk > bin you can see a ton of tools, does anybody care about what are they and what they do?

Like, really, they are just right there, and you can use them from your terminal the moment you install your JDK and configure your JAVA_HOME and PATH. Am I tripping? or do I simply just happen to not know people who actually care about this kind of stuff?


r/learnjava • • Sep 30 '25

Any advice on how to best study Java?

1 Upvotes

I'm a computer science major, and right now I am taking a lecture on Java. Last semester we learned python, and for me that was much easier in comparison and I feel like I'm behind. Are there any outside sources that you would all recommend to help learn Java better and let it stick? So far I've been told w2schools, and leetcode, but leetcode seems a bit hard for me at the moment.


r/learnjava • • Apr 13 '25

Java Full Stack for Freshers

1 Upvotes

I am a 3rd year Btech student and currently learning Java Full Stack. I just wanted to ask that, how is the market for Java full stack developer ( Honest answers plzz). After seeing the condition of market, I really feel nervous.


r/learnjava • • Dec 23 '25

Long is faster than int, Short and Byte are not that far behind Int in terms of mathematical speed in Java

0 Upvotes

Recently i got asked a simple question. are shorts better to use than in general?

Well i couldnt answer this novel question and so i went on searching and i couldnt find a proper answer for the second part. While most seemed to agree int would be faster than short, the opinions on just HOW much faster varied alot.

I saw this as a learning opportunity
So i ran a few (albeit amateur) tests to see the differences. First i did just sums for int vs short with shorts being much slower. But i learned about blackholes and like jvm can sometimes over optimize your code etc so i kind of caved and got some help for what mathematical equation would be best to see the differences. Also since bytes only go up to a few numbers i had to nest it 3 times in loops so that i had a long enough loop.

https://imgur.com/a/XDW53XU

Quick video i put together on the topic

package com.yourcompany;
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;

(Scope.Thread)
(Mode.AverageTime)
(TimeUnit.MICROSECONDS)
(value = 1, warmups = 2)
(iterations = 3)
public class MyBenchmark {
    // Using byte-sized loops (max value 127)
    private static final byte OUTER_LOOPS = 32;
    private static final byte MIDDLE_LOOPS = 16;
    private static final byte INNER_LOOPS = 8;

    u/Benchmark
    public byte testByte() {
        byte z = 42;
        for (byte i = 0; i < OUTER_LOOPS; i++) {
            for (byte j = 0; j < MIDDLE_LOOPS; j++) {
                for (byte k = 0; k < INNER_LOOPS; k++) {
                    int t = (z * 31) + i + j + k;
                    z = (byte) (t ^ (t >>> 8));
                    z = (byte) ((z / 7) + (z % 64));
                }
            }
        }
        return z;
    }

    u/Benchmark
    public short testShort() {
        short z = 42;
        for (byte i = 0; i < OUTER_LOOPS; i++) {
            for (byte j = 0; j < MIDDLE_LOOPS; j++) {
                for (byte k = 0; k < INNER_LOOPS; k++) {
                    int t = (z * 0x9E37) + i + j + k;
                    z = (short) (t ^ (t >>> 16));
                    z = (short) ((z / 7) + (z % 1024));
                }
            }
        }
        return z;
    }

    u/Benchmark
    public int testInt() {
        int z = 42;
        for (byte i = 0; i < OUTER_LOOPS; i++) {
            for (byte j = 0; j < MIDDLE_LOOPS; j++) {
                for (byte k = 0; k < INNER_LOOPS; k++) {
                    int t = (z * 0x9E3779B9) + i + j + k;
                    z = (t ^ (t >>> 16));
                    z = (z / 7) + (z % 1024);
                }
            }
        }
        return z;
    }

    u/Benchmark
    public long testLong() {
        long z = 42L;
        for (byte i = 0; i < OUTER_LOOPS; i++) {
            for (byte j = 0; j < MIDDLE_LOOPS; j++) {
                for (byte k = 0; k < INNER_LOOPS; k++) {
                    long t = (z * 0x9E3779B97F4A7C15L) + i + j + k;
                    z = (t ^ (t >>> 32));
                    z = (z / 7) + (z % 4096);
                }
            }
        }
        return z;
    }

    u/Benchmark
    public float testFloat() {
        float z = 42.0f;
        for (byte i = 0; i < OUTER_LOOPS; i++) {
            for (byte j = 0; j < MIDDLE_LOOPS; j++) {
                for (byte k = 0; k < INNER_LOOPS; k++) {
                    float t = (z * 1.618033988749f) + i + j + k;
                    z = t * t;
                    z = (z / 7.0f) + (z % 1024.0f);
                }
            }
        }
        return z;
    }

    u/Benchmark
    public double testDouble() {
        double z = 42.0;
        for (byte i = 0; i < OUTER_LOOPS; i++) {
            for (byte j = 0; j < MIDDLE_LOOPS; j++) {
                for (byte k = 0; k < INNER_LOOPS; k++) {
                    double t = (z * 1.618033988749894848) + i + j + k;
                    z = t * t;
                    z = (z / 7.0) + (z % 4096.0);
                }
            }
        }
        return z;
    }

    u/Benchmark
    public char testChar() {
        char z = 42;
        for (byte i = 0; i < OUTER_LOOPS; i++) {
            for (byte j = 0; j < MIDDLE_LOOPS; j++) {
                for (byte k = 0; k < INNER_LOOPS; k++) {
                    int t = (z * 0x9E37) + i + j + k;
                    z = (char) (t ^ (t >>> 16));
                    z = (char) ((z / 7) + (z % 512));
                }
            }
        }
        return z;
    }
}

r/learnjava • • Oct 03 '25

HELPP. I have a Technical video interview at Tesco for a Software Engineering graduate role

0 Upvotes

Hi, I have a Technical video interview for a software engineering graduate programme that I applied for. I have 7 days to prepare and submit it. What is the best way to prepare, what type of questions would come up, and what should my approach regarding answering the questions be to pass the interview.

Upvote1Downvote0Go to commentsShare


r/learnjava • • Oct 18 '26

mooc.fi for java

1 Upvotes

hi there, question for those who learned java on mooc.fi i plan on going through both sections at home and at work, i was wondering if i can "save my stuff" so i can continue from where i left off, because i will be learning both at home and at work.

and is it best to use what they ask for or vs code, ive seen videos of people using vs code??


r/learnjava • • Jul 09 '26

Simple Java console app

1 Upvotes

Hello everyone, I've been learning Java and wanted to build something practical instead of just doing exercises. Ended up making a small console app that asks how long you've had a tire and how many km you've driven it, then tells you whether it needs replacing or estimates how much life is left.

It's intentionally simple right now. It just handles basic mileage/age limits and adjusts slightly if you own a heavy SUV or EV. This was also my first time using Git and GitHub properly (commits, pushing, merging, etc.), so that was a big part of the learning experience too.

Planning to add more factors soon like road type, vehicle type, maybe a GUI version eventually. Would love any feedback on the code or suggestions for what to add next.
Repository Link: https://github.com/z0lxt/tire-life-estimator


r/learnjava • • Apr 12 '26

Question about Java class, object and functions

1 Upvotes

Hey guys, this was my fourth day learning java, I have covered variables, conditional, operator, some math, except array and loops. When I watch the tutorial, I always heard about classes, object and functions, but I don't know what that thing is. The methods, I know it some kind of block that we write to organize code and so we don't have to write it again. So what exactly are these three things, can someone exlplain.


r/learnjava • • Jul 20 '26

Learning Java

1 Upvotes

How should I go about learning Java? I learn best by doing and have pretty bad ADHD. I would be interested in lifetime payments as I am not working yet so monthly is not ideal.


r/learnjava • • May 26 '25

I want to learn java development with some partner. ANYONE INTERESTED??

8 Upvotes

I am learning java and due to it's importance in industry I want to learn it but due to less number of tutorials on YouTube I am finding it hard to grind through it. So I want if someone who is equally passionate about this can connect and we can make things work together.Also if someone can guide me through a roadmap through their experience, it would be very helpful.


r/learnjava • • Mar 20 '26

Am I cooked

8 Upvotes

I have technical interview on Monday Role is software developer Now when I am going through my projects I am realising what I have learnt I don't remember. Why it is like this I have learnt most of the things and now I can't remember much. What should I do ? Company is related to Banking Technologies : java spring boot and jdbc along with MySQL. Can I go through all these in 2 days ?

Am I cooked ??

Edit: Update The interview went well and made it to the hr round. They mainly asked abt the core Java questions and some sql queries that's all. Waiting for the results. Hope all goes well 🤞✌️

Edit 2 : Cracked the interview. Got the offer letter from the company. Monday is joining along with documents. Feeling greatful 🙂✌️


r/learnjava • • Mar 29 '25

Spring Security sucks!

0 Upvotes

Hi guys I have been trying to make spring security work in my projects. I am very familar with spring mvc and i can make good rest apis but when i try to make jwt and tokens work! I feel like giving up. I have made over 20 + new java spring projects just watching tutorials and deleting the file becuase some bug came up. Struggling with this for a month and just trying to make this work! . As a last ditch effort i generate jwt token and issue the cookies in the frontend side (nextjs) which is way easier! I always get some versioning error or some stupid bug. Noone is teahcing properly step -by step. Pls help! I even asked chatgpt to fix some bugs but it never worked


r/learnjava • • Aug 08 '26

Java coding

5 Upvotes

hey there I want to start coding and actually thinking of starting with Java, can anyone suggest where can start and how to start and what are the things to keep in mind


r/learnjava • • Mar 08 '20

What is the coolest thing you can think of to do with Java?

5 Upvotes

I can be anything.


r/learnjava • • Dec 03 '24

Java for Aspies?

0 Upvotes

Firstly, I am autistic. I've tried to learn java from more “traditional” languages (C# & Python), but I just can't understand java and OOP in general. I just want to learn enough to make Minecraft mods (Minecraft subs told me to post here instead), so does anyone have anything that could help me understand java? My main problems are with general OOP and Javas buses.


r/learnjava • • Apr 21 '19

Why am I learning about inheritance in my 6th week of my Java 1 class, yet the Helsinki MOOC introduces it in week 10?

5 Upvotes

Is this just a different way of doing things? So far I haven't been impressed by the quality of my schools programming courses, so I'm predisposed to thinking this is another reason these classes are dogshit. Is that true?

I realize that week 6 and week 10 sound similar, but let me lay out my class so far, where it doesn't feel like I've learned 6 weeks' worth of programming:

week 1 - Introduction, setting up the IDE, etc.

week 2 - learning the primitive data types

week 3 - how to code control statements

week 4 - how to code methods, handle exceptions, and validate data

week 5 - midterm

week 6 - all of a sudden we're on inheritance

I learned a good amount through the MOOC (and would be constantly pulling my hair out if I wasn't proactive and worked through the MOOC first, however I'm only on week 6) and feel like the classes curriculum is sporadic and vague. I made this post because I have an assignment about inheritance and I know nothing about it because I haven't gotten to it in the MOOC yet.


r/learnjava • • Apr 18 '21

Why is Java still the third most in demand programming language?

0 Upvotes

I understand why Python & Javascript are the most in demand at this moment, but why is Java still in demand? other than android development, why is Java still in use when there are much better alternatives?


r/learnjava • • Apr 04 '25

Need advice where to start Java to land a job ASAP

19 Upvotes

Hi!

I'm a CS grad 2024 passout from a tier 3 college. I had backlogs then. I got my degree 2 weeks ago after clearing my backlogs recently.

I worked for 6 months in a non IT job and resigned a week ago to transition my career into Software. I had very poor faculty in my college often repeating the same sentences from a book and they had no idea about programming. I lost interest in coding coz of them.

Now, I want to learn Java to get my first Software job to step into the industry and build my future in it. I'm afraid of Java and know almost nothing about it.

Please, anyone experienced help me to crack my first job. I want to get back on track and would be very thankful for your advice. 🙏


r/learnjava • • May 22 '25

People say Java is slower than Go but I think that is wrong?

21 Upvotes

People say Java is slower than Go but I think that is wrong because Java is multi platform and GO is not. I think if we could compile the Java code into different platforms like GO then Java would be even faster than go but the JVM part affects a lot the performance for be doing all those small compilations of the fly when running Java code. I personally still like more the Java code than GO code it looks cleaner in my opinion.


r/learnjava • • Jan 30 '23

I'm a new student and im worried with ChatGPT.

0 Upvotes

So, i've never programmed before, and i just started studying Java, im really liking it and i've just started learning "IF/ELSE".

But, as a beginner, im very worried that im learning java for nothing, since everyone is talking about ChatGPT, and how it will at least have a huge impact on the need for beginners, since it will be at least capable of solving basic problems.

So, i come here to ask you guys, is it even worth it to still study java?

Or should i quit while its not "too late"?


r/learnjava • • Jun 03 '15

Best Book to Learn Java Programming for Beginners?

Thumbnail
java67.blogspot.sg
7 Upvotes