Friday, January 29, 2016

public class JavaClass { public static void main(String[]args){ } }

Classes and Methods:
A class is a set of rules that will define an object in a later program, they are made to hold methods which are consequently the rules that formulate every object and these methods are written with different parameters and manipulated to benefit the code.
Ex. of a class:
public class Blog{

this will be what contains the rules and settings to create an object called Blog. They are usually started with a capital letter and are written with brackets which are what holds the code inside of the class.
Ex. of methods:
public class Blog{
int amountOfPosts
  public static void main(String[]args){

  Blog myBlog = new Blog(2);
  Blog myBlog2 = new Blog();

  //Will do the same as myBlog

  public Blog(){
  public Blog(int a){
  amountOfPosts = a;
the main method is the most important method in Java programming, it helps define where a program starts and inside of it's brackets is where the program should be defined for the JRE(Java Run-time Environment) to read and run the program. The parameter of String[]args inside the parenthesis next to main is in itself quite complicated, it is an array of Strings that are assigned to variable args, it helps the program know that it is running.
public Blog() is a method that is defined as a Constructor, it defines what an object of class Blog must have when it is defined. In this case myBlog is an object of class Blog and has an amountOfPosts of two, this is assigned in the parenthesis next to Blog when creating a new object
and is ultimately assigned on the constructor, if the parameter of an object is empty such as myBlog2 it will use the constructor that has the same parameters.
There are different ways of writing a method that have to do with encapsulation (private, public, protected) but there is different types of methods as well depending on whether you want a return or not.
public void setAmountOfPosts(int a){
  amountOfPosts = a;
this method will not give you a return because is a void method, this means that it does not by itself hold to any data but it will modify the program in any way you want
public static String getATitle(String t){
int title = t;
return title;
this is a method that requires a return because it holds on to data, in this case is a String data. It is not required to use the static modifier but for this type of method it is recommended because of recursion (Will probably write another post about this theme.)

Friday, January 22, 2016

int primitiveData = 0;

In Java programming, Primitive Data is the most basic storage of data. Java is an Object oriented programming language, which means that most of the programming will be aimed towards and shaped around creating and modifying objects. The first step for that is Primitive Data.
There are several different ways to identify primitive data with variables. Java like every other programming language requires an IDE(Integrated Development Environment) which is any text editor and a Compiler such as Eclipse ( to build and test programs, every IDE will need a copy of the Java Development Kit (JDK) ( to access it download it and the IDE should automatically find it. I personally enjoy using Eclipse because as well as being a compiler it is also an IDE as well. Every line of code should be finished with a semicolon and any comment that you want to make shall be written with two forward slashes Ex: //This is a comment.
Different ways to identify variables in Java:
int (This identifies a variable to an integer or whole number. Ex: int x = 10; this will set variable x as an integer to the number 10, creating primitive data.)
boolean (This identifier will set a variable to either a true or false, the use of this is varied but it is mostly used for when a loop or a conditional requires a boolean, but is also not necessary at that point either. Ex: boolean end = false; <= Will set variable end to false)

For the next Identifiers you'll need to understand a basic concept of bit data, which means that a bit is a number in binary system (a 0 or 1), this makes up everything in programming, but it is unnoticeable. a byte is a gathering of 8 bits and everything is saved on bytes.
double (This identifier will set a variable to any rational number and can reach up to 64 bits or 8 bytes. Ex: double x1 = 10.32; It is also not necessary to always set an identifier with a number value as a number but you are also allowed to utilize operations such as x1 = 2.3 * 14; which will output 32.2, if an int is used for this same operation it will round to the nearest whole number it will set x1 to 32.)
float (This identifier will set a variable just like a double but is then used for different purposes, and is saved as 32 bits or 4 bytes.)

The next identifier deals with characters and it consequently called a char, a char identifier is used for single characters that can be typed on your keyboard. (Ex. char a = 'A'; to identify a char variable you have to type whichever character you want to assign the variable to inside single quotes.)
Strings: a string identifier is a special one because it is a combination of a seemly unlimited amount of char identifiers. It allows for an extensive use of characters. (Ex. String b = "This is String b :)";)
there are multiple special characters that you cannot use within strings but that will be talked about at a later time.