First of all, congratulations because you are trying! Secondly, It's completely normal to not get programming when you are doing it for the first time. I used to fail myself in computer science when I started learning to code. Coincidently, my first language was also Java. I was like what is this InputStreamReader read = new InputStreamReader() and BufferedReader. Why do we even need this? Why can't we just do read or input.
But, as you gradually understand more and learn more you will appreciate the beauty of things. Right now what you should do is take a break, and try to think what is it that you are finding hard? There is one tip which I followed and it has helped me always:
Make sure you understand every word and why it has been used in the code you write?
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
Learning to program is made up of two parts according to me:
So let's take this very easy code and break it down, and ask a question for everything you have written.
P.S. you may already know what I am talking about but this is just about the approach.
public
access specifier(tough term though), which is used by java to know who all can use this class or method.encapsulated(tough term again), it means to keep things locally wherever we want and not expose it to anyone who doesn't need it.public before the class and everything will work still fine, Will it still be public? I am not sure. You can always find it out.So you get the idea! This is how I learn a language and as you build your vocabulary, learning subsequent languages will be very easy.
This is like the brain of what you do, learning language can make you speak, but logic will make you a poet. The amazing things you can do with code is with logic. Computers are dumb and after learning the language you can now talk to it. So you need to tell it what to do.
There are innumerable ways to improve your logic and here are few which I have followed:
1
22
333
4444
***
**
*
These simple exercises are very helpful when you are fresh. They get you into a different way of thinking.
I don't have a live example to give you but will share what I did. There is a thing called as SOP and POS expressions. I wrote a code to convert one to other. Trying to do something like this has multiple benefits. You undoubtedly improve your programming skills but you also develop a deeper insight into the problem.
Try small, like searching and sorting and gradually keep increasing the difficulty.
That was all the blabber from a novice developer. I would be more than happy if I was able to help you even 1%. And yes, I am now a developer by passion and I went ahead doing my bachalors in Computer Science.