r/learnjava • • Sep 29 '15

[Request - secondary technical school] Is somebody willing to help me setting up a rough plan for my final project?

0 Upvotes

As a requirement for graduation in my school, we, a team of 4, are compelled to program a software (desktop for windows) for a firm that we had to keep in touch with ourselves. Now, we basically lost 5 years of programming experience due to shitty teachers and I'm currently trying to catch up by working through "Head First Java" and I'm going to take a look at another book after that. I'd like to receive some help on how the software should be built. By that I mean what kind of "methods" (not in programming context) I should use, e.g. Inheritance and what not. We will be using Java, hence why I'm writing this post in this sub, and SQL for the database.

The primary function of the software is to save customer, bill and so on into the database and allow the user to retrieve and display those information.

I'm not asking for much, just a basic plan on how it should be set-up etc. from someone who has experience in programming a management software. This project is crucial because if we fail this, we won't be allowed to take the final exams.

If someone can help me, please send me a private message or post any suggestions here. Thanks!


r/learnjava • • Nov 22 '16

Can anyone tell me why this compiles successfully but I still get errors

0 Upvotes
import java.io.*;

public class RetailItem
{
    private String description;
    private int units;
    private double price;
    public  RetailItem()
    {
    }
    //Constructor with arguments
    public RetailItem (String des, int u,double p)
    {
	     description = des;
	     units = u;
	     price = p;
    }
    //Mutator function description
    public void setDescription (String des)
    {
	    description = des;
    }
    //Mutator function price
    public void setPrice (double p)
    {
	     price = p;
    }
    //Mutator function units
    public void setUnits (int u)
    {
	    units = u;
    }
    //Accessor function for units
    public int getUnits()
    {
	    return units;
    }
    //Accessor function for description
    public String getDescription ()
    {
	    return description;
    }
   //Accessor function for  price
    public double getPrice()
   {
	   return price;
    }
}
class RetailTest

{
    public static void main (String[] args)
	    {
		    String str = "shirt";
		    //RetailItem with three objects
		    RetailItem r1=new RetailItem ("jacket",12,59.95);
		    RetailItem r2=new RetailItem ("Designer Jeans",40,34.95);
		    RetailItem r3=new RetailItem ();
		    //function call to set values
		    r3.setDescription(str);
		    r3.setUnits(20);
		    r3.setPrice(24.95);
		    //printing data
		    System.out.println ("Description\tUnits on Hand\tPrice");
		    System.out.println("Item#1\t"+r1.getDescription()+"        \t\t"+r1.getUnits()+"\t\t"+r1.getPrice());
		    System.out.println("Item#2\t"+r2.getDescription()+"    \t\t"+r2.getUnits()+"\t\t"+r2.getPrice());
		    System.out.println("Item#3\t"+r3.getDescription()+"    \t\t"+r3.getUnits()+"\t\t"+r3.getPrice());

		    System.exit(0);

	    }
}

r/learnjava • • Feb 24 '15

What is the fastest way to learn Java?

0 Upvotes

I have been procrastinating a lot in my class and I need to do a project, it is due in a week and I have that much time to study to start programming. What would you guys recommend is the best and fastest way to learn?


r/learnjava • • Jul 25 '24

Anyone needs a remote Software intern?

0 Upvotes

So I'm still studying at college but this being my last year I have a lot of free time to get real world experience. I can do a little of everything, I can code with SpringBoot, .NET, NodeJS or Django. Also React and Angular, and SQL databases. I already know Git too.

If these skills are not enough I can still learn a lot by myself in my free time and catch up to your required skill set.

If you are interested please send me a DM and let's talk!


r/learnjava • • Apr 17 '24

Implementing efficient Stack data structure in Java

0 Upvotes

Having already solved the Keystrokes problem on Open Kattis using Python3, I'm now trying to re-implement the same algorithm in Java. I've come up with below class which compiles and runs fine but runs into the time-out error when I submit for evaluation. What can I do to make it more efficient?

import java.util.*;

class lyklagangriti {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		Stack<Character> l = new Stack<>();
		Stack<Character> r = new Stack<>();
		for(int i=0;i<s.length();i++) {
			char c = s.charAt(i);
			char item;
			switch(c) {
				case 'L':
					item = l.pop();
					r.push(item);
					break;
				case 'R':
					item =r.pop();
					l.push(item);
					break;
				case 'B':
					l.pop();
					break;
				default:
					l.push(c);
			}
		}
		for(char c : l) {
			System.out.print(c);
		}
		while(r.size() > 0) {
			char c = r.pop();
			System.out.print(c);
		}
		System.out.println("");
	}
}

Edit

Special thanks to /u/Cengo789 for suggesting ArrayDeque instead of Stack, and to /u/-doublex- for suggesting BufferedReader instead of Scanner for reading the input. After implementing these ideas, the program passes the test in only 0.21 seconds!

import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class lyklagangriti {
	
	public static void main(String[] args) throws IOException {
		//Scanner sc = new Scanner(System.in);
		BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
		String s = bi.readLine();

		//String s = sc.nextLine();
		Deque<Character> l = new ArrayDeque<Character>();
		Deque<Character> r = new ArrayDeque<Character>();
		for(int i=0;i<s.length();i++) {
			char c = s.charAt(i);
			char item;
			switch(c) {
				case 'L':
					item = l.pollLast();
					r.addFirst(item);
					break;
				case 'R':
					item =r.pollFirst();
					l.addLast(item);
					break;
				case 'B':
					l.pollLast();
					break;
				default:
					l.addLast(c);
			}
		}
		StringBuilder sb  = new StringBuilder(l.size() + r.size());
		for(char c : l) {
			sb.append(c);
		}
		for(char c : r) {
			sb.append(c);
		}
		System.out.println(sb);
	}
}

r/learnjava • • Apr 23 '24

I was trying to make auth work and then I realized I used a deprecated solution

0 Upvotes
<parent>

	<groupId>org.springframework.boot</groupId>

	<artifactId>spring-boot-starter-parent</artifactId>

	<version>2.0.1.RELEASE</version>

	<relativePath/> <!-- lookup parent from repository -->

</parent>



<properties>

	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

	<java.version>1.8</java.version>

<ec-profile>default</ec-profile>

</properties>

Can someone find me a repository that uses 3.2.5 and Java version 17? I wasted 5 hours on this. Holy fuck, Spring Boot is driving me crazy. I thought that the old solution might work even if it were deprecated, but the solution is so old although the tutorial was somehow posted like 2 years ago. I think I am going to go insane.

I need something with roles, JWT tokens, and that works with REST controllers.


r/learnjava • • Apr 28 '24

Just started program

0 Upvotes

Hello all, I have just started programming and currently programming in Java. My college have ended and haven't got placed. How much time I would required to get a job actually. Also which particular thing I should learn first, also suggest me some hack to get into that programming mindset. It would be really helpful for y'all if you assist me with this.


r/learnjava • • Dec 12 '20

Why is learning git commands necessary?

0 Upvotes

I just used GitHub interface and IntelliJ's plugin with 0 need to open a console and type cryptic commands. Am I evil? I mean, my teacher insists on using that Git Bash thing but I understood everything better by clicking on things at GutHub.com

I don't get why should I invest my time on learning something I don't need at all...


r/learnjava • • Dec 09 '20

I NEED HELP WITH MY CODE

0 Upvotes

So I was trying to code a small game with a simple gui. Don't worry about what the game is supposed to be about, I didn't even get close to that. I got stuck when trying to create a JButton that increased a counter... Here is my code:

import javax.swing.; import java.awt.; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;

public class Window implements ActionListener {

private static JLabel moneyCounter;

long count = 0;

public static void window() {

    JFrame frame = new JFrame();
    frame.setSize(500, 500);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("Game");
    frame.setLayout(null);

    JButton button = new JButton("Button");
    button.setSize(100, 30);
    button.setBackground(Color.black);
    button.setLocation(200, 235);
    button.setVisible(true);
    frame.add(button);
    button.addActionListener((ActionListener)this);

    moneyCounter = new JLabel("0");
    moneyCounter.setSize(100, 30);
    moneyCounter.setHorizontalAlignment(SwingConstants.CENTER);
    moneyCounter.setLocation(200, 135);
    frame.add(moneyCounter);
    moneyCounter.setVisible(true);

    frame.setVisible(true);

}

@Override
public void actionPerformed(ActionEvent e) {
    count++;
    moneyCounter.setText(String.valueOf(count));
}

}

This is the error message that I get: java: non-static variable this cannot be referenced from a static context

Also, I know what the problem is, and I know what I am doing wrong and why it doesn't work, but I don't know how to fix it! I can't just make the method a non-static method, because I have to access that method from the main method, and that wouldn't work if they weren't both static, and the main method is always static, so this one has to be static too, right? How can I fix this? Thanks in advance :)


r/learnjava • • Apr 17 '22

Need advice on how to approach reading a big java book

0 Upvotes

Hi,

I have completed mooc.fi course, it was amazing, but I am still missing a lot of core java knowledge.

I want to start building projects and spend about 2 hours per day in it, while also reading the book Core Java Volume I & Core Java Volume II. They are both more than 1000 pages so I was going to spend about 45 minutes per day on reading the book.

Is it a good way to learn? I was planning to make notes and try to implement some concepts from the book immediately after. Any tipps appreciated.


r/learnjava • • Aug 10 '23

Need help splitting string with regex

0 Upvotes

I'm trying to split a list of strings while keeping the delimiters ("+", "-" , "*" , "/") but I keep running into this problem where a string will also split at decimals as well. Given the input [-14.0x, -12.0] it will return [-, 14., 0x, -, 12., 0] but the expected result is [-, 14.0x, -, 12.0]. Any help is greatly appreciated.

private List<String> splitTerms(List<String> terms) {
    List<String> splitTerms = new ArrayList<>();

    for (String term : terms) {
        String[] operatorAndTerms = term.split("(?<=[+-/*])");

        for (String split : operatorAndTerms) {
            splitTerms.add(split);
        }
    }
    return splitTerms;
}

r/learnjava • • May 09 '15

[Help] Just finished first java module in college, looking to take my studies further

0 Upvotes

I have just finished year 2 in a computer sceinece degree which had a module for java, it is with the open university and the module was object orientated java programming. I've done really well in this and have my exam in a few weeks but I want to take this further.

I have seen several pages posted here on learning java but a lot of it seems to cover what I have already done, would anyone be able to advice a good site to take my studies further and maybe start using thing like java swing. Or even simple program challenges I can try myself.


r/learnjava • • Sep 29 '18

Why is my program not working as intended(convert numbers to their english representation)?

0 Upvotes

r/learnjava • • Dec 31 '19

Best Java Object Oriented Design Course?

0 Upvotes

What is the best Java Object Oriented design course available online - Covers UML design, tools etc for designing Java classes / architecture?


r/learnjava • • Sep 22 '18

What exactly object is?

0 Upvotes

What happens internally when creating an object? What information is stored in ram about particular object? Object is nothing but a value in heap? I want to have deep insights about object.


r/learnjava • • Jul 09 '19

Am I fit for a CS degree?

0 Upvotes

I have a tough time learning the basic concepts of oop in Java and can't write the programming problems on my own, always require an outside help. I feel like even if I tried hard, I wouldn't be a good programmer. I still have time to give up and change my major so I'm looking for a little advise here.


r/learnjava • • Jul 11 '19

1 week into java, need help please.

0 Upvotes

Hello! As you can see from my thread title, I'm 1 week into java with no prior programming experience so yea I'm extremely bad at this. I was wondering if anyone could suggest me some resources to be the best java developer that I can be (learning java resources and also patterns to follow that would make me a better java developer). I'm currently using MOOC


r/learnjava • • Oct 28 '18

→ /r/javahelp ← Writing a function in java

0 Upvotes

Hi, I am new to java. Can you please tell me which is the basic semantic to create a function in java? I am at the beginning, I want to know how does it start a function in java

Let's assume I have the object ''player'' and I want this object moves straight up everytime the X button on a joystick is pressed.

Well, basically... how can this be done in java? This is a function, right? Ok, how can it be performed (the basiacally initial code)?


r/learnjava • • Nov 22 '19

Help why doesn't this work

0 Upvotes

package dungeon.game.pkg2;

import java.awt.Color;

import java.awt.Container;

import java.awt.Font;

import java.awt.event.ActionListener;

import javafx.event.ActionEvent;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JTextArea;

public class DungeonGame21 {

JFrame window;

Container con;

JPanel titelnamepanel, titelstartpanel, gamemaintextpanel;

JLabel titelnamelabel;

JButton titelstartbutton;

Font titelnamefont = new Font("Times New Roman", Font.PLAIN, 80);

Font normal = new Font("Times New Roman", Font.PLAIN, 30);

JTextArea gamemaintext;

TitleScreenHandler tsHandler = new TitleScreenHandler();

public static void main(String[] args)

{

DungeonGame21 DungeonGame2 = new DungeonGame21();

}

public DungeonGame21()

{

window = new JFrame ();

window.setSize(800, 600);

window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

window.getContentPane().setBackground(Color.BLACK);

window.setLayout(null);

window.setVisible(true);

con = window.getContentPane();

titelnamepanel = new JPanel();

titelnamepanel.setBounds(100, 100, 600, 100);

titelnamepanel.setBackground(Color.BLACK);

titelnamelabel = new JLabel("Dungeon Game 2");

titelnamelabel.setForeground(Color.WHITE);

titelnamepanel.add(titelnamelabel);

titelstartpanel = new JPanel();

titelstartpanel.setBounds(250, 400, 300, 50);

titelstartpanel.setBackground(Color.BLACK);

titelstartbutton = new JButton("Start");

titelstartbutton.setBackground(Color.BLACK);

titelstartbutton.setForeground(Color.BLACK);

titelstartpanel.add(titelstartbutton);

titelstartbutton.addActionListener(tsHandler);

titelstartbutton.setFont(normal);

titelnamelabel.setFont(titelnamefont);

con.add(titelnamepanel);

con.add(titelstartpanel);

}

public void gamescreen()

{

con.remove(titelnamepanel);

con.remove(titelstartpanel);

gamemaintextpanel = new JPanel();

gamemaintextpanel.setBounds(100, 100, 600, 250);

gamemaintextpanel.setBackground(Color.BLACK);

con.add (gamemaintextpanel);

gamemaintext = new JTextArea();

gamemaintext.setBounds(100, 100, 600, 250);

gamemaintext.setBackground (Color.BLACK);

gamemaintext.setForeground (Color.WHITE);

gamemaintext.setFont(normal);

gamemaintext.setLineWrap(true);

gamemaintextpanel.add(gamemaintext);

}

public class TitleScreenHandler implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

gamescreen();

}

}

}

This is a game I am making but so far I haven't gotten past the title screen because my start button doesn't work.

so I think it should work but it gives an error at the "public class TitleScreenHandler implements ActionListener" the error says "DungeonGame21.TitleScreenHandler is not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener.

If anyone can say what is wrong please do help me hope this is the right subreddit to post this on.

Thank you!


r/learnjava • • Feb 11 '19

Resources for learning java

0 Upvotes

Hi guys, can anyone help me with the best resources for learning Java? I Don’t mind paid or free resources.


r/learnjava • • Sep 11 '21

M1 Macbook TMC not opening

0 Upvotes

Hi, i tried installing TCM for the MOOC exercise but it's not installing, i downloaded sdk 11 eclipse and the MOOC, i tried right click opening it but it crashes (i'm on the latest stable big sur)


r/learnjava • • Sep 18 '21

how popular is Rust for backend in FAANG level companies?

0 Upvotes

I am kinda new to backend and I would like to learn a language that can help me write production level code. I have heard about verbose style of Java code and how the syntax for Rust is not elegant. however I really like the idea of a system level language with smaller memory footprint.
Also I know Java has been around much longer and is a mature language but based on my brief research on documentations for both languages, I found Rust docs more engaging. Do you think for a new backend developer with around 3 YoE Rust is the good choice in 2021?


r/learnjava • • Jan 26 '21

First Java Project Ideas

Thumbnail self.javahelp
0 Upvotes

r/learnjava • • Dec 29 '20

How do I validate the login details when the password is Hashed?

0 Upvotes

I can validate it without the hashing by comparing the values with the ones in the database but I'm baffled as to how I do it when the password is hashed. I have a table called hashedPasswords that has the userName, seed & hash. How would I validate in this way?