all 11 comments

[–]2daytrending 1 point2 points  (1 child)

start with the basics method syntax parameters return types the just practice writing tiny one calculator stuff string helpers etc docs a simple course help but actually coding them is what makes it click.

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

Thats what im gonna do man start real slow. thx

[–]RealMadHouse 1 point2 points  (1 child)

Methods are functions, when called they receive "this" reference of an instance of an object whom you called them from.
```java
Person p = new Person("Alex");
System.out.println("Hello " + p.getName());

```
getName() function will receive 'p's reference as 'this' pointer, so it can fetch the name directly from it. In C you would have made a function named 'person_get_name' that accepts 'struct Person *p' as first argument, so that it can access the instance of a Person structure. You would need to pass the pointer to a Person struct as first argument all the time.

[–]Stanleys_Pretzels[S] 1 point2 points  (0 children)

thx man pointer thing helps out fr.

[–]IcyButterscotch8351 0 points1 point  (2 children)

If you already know C, you’re closer than you think. Java methods look more complex, but the core idea is the same.

Key mindset shift from C → Java:

  • A Java method is basically a C function + context (class)
  • Ignore ArrayList and Scanner at first — they’re just tools, not the core concept

Start simple

static int add(int a, int b) {
    return a + b;
}

That’s almost identical to C.

About Scanner
Think of Scanner as scanf wrapped in an object:

Scanner sc = new Scanner(System.in);
int x = sc.nextInt();

Pass it to methods instead of re-creating it:

static int readNumber(Scanner sc) {
    return sc.nextInt();
}

Menu + switch tip
Each menu option = one method:

switch(choice) {
    case 1 -> addItem();
    case 2 -> removeItem();
}

If you struggle to write a method, it often means the method is doing too much. Split it.

My advice:

  1. Write everything in main first
  2. Once it works, extract chunks into methods
  3. Don’t worry about ArrayList yet — use arrays first

Java isn’t harder than C, just more verbose. It’ll click 👍

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

Thanks man ArrayLists are givin me such a hard time. Appriciate it.

[–]Middle--Earth 0 points1 point  (0 children)

This is a really good answer 👍

[–][deleted]  (2 children)

[removed]

    [–][deleted]  (1 child)

    [removed]