Hey everyone! I'm new to computer science and I've learned C as my first programming language. However, I'm having a tough time grasping Java methods; they seem much more complicated than C functions. I get that the concept is similar, but the addition of ArrayLists, arrays, and Scanner usage is throwing me off. Can anyone offer some tips or resources? I haven't found a YouTube video that addresses my specific struggles, and I'm currently trying to implement methods in a menu problem using switch cases, which is where I'm hitting a wall. Any help would be greatly appreciated!
2 Answers
Start by mastering the basics of method syntax, parameters, and return types in Java. Practice by writing small programs – even simple calculators or string helpers can help! A basic course might provide some structure, but the key is just getting hands-on and coding those methods to make them click.
If you have a background in C, you're not as far off as you think! Java methods may look more complex, but at their core, they're much like C functions, just wrapped in a class context.
To ease into it, try ignoring `ArrayList` and `Scanner` at first – focus on simple methods:
static int add(int a, int b) {
return a + b;
}
For `Scanner`, think of it as the Java equivalent of `scanf`:
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
Then, pass `Scanner` instances to your methods rather than recreating them each time! For your menu, each option can correspond to a method:
switch(choice) {
case 1 -> addItem();
case 2 -> removeItem();
}
If you find a method tricky, it likely means it's trying to do too much. Start with everything in `main`, get it working, and then break it down into methods. Don’t stress about `ArrayList` for now; stick with arrays initially. Java isn't harder than C, just a bit more verbose. You'll get it! 😊

Thanks man! I’m really struggling with ArrayLists right now. Appreciate your guidance!