Of course, you can. You're better off learning the fundamentals of Java first.
Up to Java Arrays/OOP 1 should be enough to start scripting. But the more complex script you're making, the more Java you should learn to make it easier and cleaner. You may even find making some random simple Java apps to be fun as well. You don't need to stick with scripting necessarily
https://www.programiz.com/java-programming
Probably the best scripting tutorial and where almost everyone starts
https://osbot.org/forum/topic/115124-explvs-scripting-101/