Coding with pugal
If you're struggling with learning Java, you're not alone. In this note, we'll go
over everything you need to know to get started writing great Java programs.
Before you can code anything in Java, there are a couple of things you have to have
installed, such as an IDE (Integrated Development Environment).
Here, we'll be using Eclipse, which is a program that makes it easier to write
code.
To get started creating a Java program, right-click in the package explorer and go
to new Java project. Give it a name and click finish.
Then, expand the drop-down and right-click the src folder, go to new class and give
it a name, and check the box that says public static void main string args.
Variables are used to store data, and in Java, we have primitive types such as int,
double, and char. You can also create non-primitive types like string.
You can call methods on non-primitive types, and Eclipse makes it easy to see all
the available methods for a particular variable.
In Java, a method is a block of code that performs a specific task and can be
called from anywhere in the code. A method can take parameters and return a value.
It is useful to package complicated code into a method to avoid repetition.
1) The method declaration consists of the method name and any code inside the curly
brackets.
2) Use the method name and parentheses to call a method.
3) You can add parameters to a method and pass them in the parentheses when calling
it.
4) You can use conditional statements, like if-then, to run specific code based on
certain conditions.
5) A loop, like a for-loop, can be used to repeat a piece of code multiple times.
6) Java is an object-oriented programming language, and a class can be used as a
blueprint to create objects.
7) Objects have attributes and methods that define their behavior.
Thats all finally you learned little bit information about java.