I just started coding. I know how to do the basics, but how do I learn how to write complicated code? It seems impossible. Could you guess suggest some ways to learn how to code complicated code?
Do yourself a favour, do not just jump into the complicated stuff. Work up to it. If you have not yet viewed the tutorials in Greenfoot and Java, I would suggest you do so first. Java has many trails of lessons at The Java tutorials. Then, look over the Greenfoot API and get well versed in those methods, all of them. Many good scenarios can be written with just the code provided by the Greenfoot API. Then look over the Java API, just to see what is available there. The link to the Java API is also on the page the link above refers to. By knowing what is there, you can reference it later, if and when you need it. Finally, if you do find it difficult to create code to do what you intended, you can post here for specific help.
The key is to ask for help when you need it. When you want to do something, have a think about how to do it and write what code you can - but if you get stuck, just post it on the gallery and ask for help.
You can also look at other people's code, and try to figure out how it works. You can learn a lot that way!