Primitive Data Types

Hello, how are you doing? well i am fine indeed.On my last post we talked about object inheritance, an inheritance in the viewside of coding. Today, we’ll still talk about OOP because there is so much we need to cover, now we’ll talk about Primitivedata types in Java. First I apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

Java programming language is statically-typed, which means that all variables must be declared before they can be used, so this will involve stating the variable’s type and name just like you already know :

int = 1;

You see… this will relate to primitive data types, “why?” you might ask, it’s because that int is one the 8 primitive data types that the Java language use, before we’ll get to the 8 of the primitive data types, let’s find the definition of primitive data types itself.
Primitive data types is a data types that directly contains value, now like refference data types, that reffers to an object(we’ll talk about that later).

Now that we know its definitions let’s find out the 8 primitive data types, here is the list with its explanation :

  • byte: The byte data type is an 8-bit signed two’s complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable’s range is limited can serve as a form of documentation.
  • short: The short data type is a 16-bit signed two’s complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). As with byte, the same guidelines apply: you can use a short to save memory in large arrays, in situations where the memory savings actually matters.
  • int: By default, the int data type is a 32-bit signed two’s complement integer, which has a minimum value of -231 and a maximum value of 231-1. In Java SE 8 and later, you can use the int data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of 232-1. Use the Integer class to use int data type as an unsigned integer. See the section The Number Classes for more information. Static methods like compareUnsigned, divideUnsigned etc have been added to the Integer class to support the arithmetic operations for unsigned integers.
  • long: The long data type is a 64-bit two’s complement integer. The signed long has a minimum value of -263 and a maximum value of 263-1. In Java SE 8 and later, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 264-1. Use this data type when you need a range of values wider than those provided by int. The Long class also contains methods like compareUnsigned, divideUnsigned etc to support arithmetic operations for unsigned long.
  • float: The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the Java Language Specification. As with the recommendations for byte and short, use a float (instead of double) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to use the java.math.BigDecimal class instead. Numbers and Strings covers BigDecimal and other useful classes provided by the Java platform.
  • double: The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the Java Language Specification. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency.
  • boolean: The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its “size” isn’t something that’s precisely defined.
  • char: The char data type is a single 16-bit Unicode character. It has a minimum value of 'u0000' (or 0) and a maximum value of 'uffff' (or 65,535 inclusive).
The example and definition of those Primitive data types are obtained from Java documentary
 Conclusions 
  • Java programming language is statically-typed. 
  • All variables must be declared before they can be used
  •  Primitive data types is a data types that directly contains value, now like refference data types, that reffers to an object(we’ll talk about that later).
  • Java documentary 
 

Object Inheritance

Hello, how are you doing? well i am fine indeed.Since we talked about OOP much lately, let’s just get into one more important thing that OOP provides for us programmers or coders, which is an inheritance.We’ll get into it’s deep meaning and we’ll understands it more. First I apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

 Okay, there is one more important thing in OOP that i want to talk about, which is an object inheritance, before we get to coding object inheritance, let’s just get the general explanation for inheritance.
Inheritance is all part of a person’s estate/assets that is given to an heirs once the person is deceased or dead. An Inheritance basically is a cash endowments that is given to it’s younger heirs from the people that are deceased. If at the time of death a will is not in place, determining the rightful heirs can be a much more complicated matter.

Wait!! we’ve gone to far now! Pheww, I lost my tracks. Let’s get back to coding, now we’ve understand what inheritance in general means, let’s get to OOP inheritance. If an inheritance in general lead to cash endowment or assets, coding inheritance is a bit different, just imagine a bycicle superclass is bycicle then after that comes another placements, types of bycicle, there are mountain bike, tandem bike etc… now the types of the bycicle are the class that inherits from bycicle, both of them had their own properties but will, have the properties that is passed down from superclass Bycicle, if you’re confused just read this, in coding an inheritance is when an object is based from a prototype of another object, using the same implementation (inheriting from object or class) specifying implementation of the object to maintain the behavior to be similar.

There we go! now that’s a coding inheritance, in coding we won’t be confused with an heirs and assets(haha). Now that we know what inheritance in coding is, let’s get some more information about object inheritance, there are 5 types of inheritance that I know, which is :

  • Single inheritance: Where the subclasses of an object will inherit the features of one superclass. A class acquires the properties of another class.
  • Multiple inheritance: Where one class can have more than one superclass and the object will inherit features from all parent classes.
  • Multilevel inheritance: The class A serves as a base class for the derived class B, which in turn serves as a base class for the derived class C. The class B is known as intermediate base class because it provides a link for the inheritance between A and C. The chain that we got from A, B and C is usually well known as an inheritance path
  • Hierarchical inheritance: Where one class of an object will serves as a superclass (base class) for more than one sub class.
  • Hybrid inheritance: A mix of two or more of the above types of inheritance.

Conclusions

  • General : Inheritance is all part of a person’s estate/assets that is given to an heirs once the person is deceased or dead.
  • Coding :  inheritance is when an object is based from a prototype of another object, using the same implementation (inheriting from object or class) specifying implementation of the object to maintain the behavior to be similar.

Byte code, Machine code, Source code

Hello, how are you doing? well i am fine indeed.Last time we talked about OOP or Object Oriented Programming, we see how OOP can benefit us. We talk about it’s definition, it’s example, it’s advantages and stuff.Now we’ll talk about a compiled programming language, since Java is a compiled programming language. First I apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

Probably you already know that java is an OOP and compiled programming language, but what is the meaning of compiled programming language, what is it benefitial? well basically a compiled programming language is a programming language that compiles instruction that the operators write into bytecode or machine language with the help of an IDE.Another explanation is, A compiled language is a programming language that its implementations are typically based to be compilers (translators that will generate machine code from the source code that operators write), and not interpreters (step-by-step instruction executors of the source code itself, where there are no pre-runtime translation that takes place).


Now you might wonder, what the heck is bytecode, machine code and source code is? good question, and as for that I will answer. What is bytecode? Bytecode, also known as p-code or a portable code, is a form of instruction that is set and designed for efficient execution by a software interpreter, that is its general definition, but… as for the Java bytecode, bytecode is a set of instruction that is created by the Java virtual machine. Each bytecode is composed from one or two bytes that represents the instruction (p-code).

Not to much of a difficult things right? well then… let’s move to machine code. What is a machine code? let’s just divide it into 2 part: first is the machine, the machine represents our computers or any machine that run codes, second… code is a Code!!. Well as for the explanation is, a computer programming language that uses binary or hexadecimal insturction that consist of one and zero(bits) that the computer can responds to directly using it’s central processing unit (cpu). Phewww… easy right? now that you understand what machine code is you could get a deeper meaning in coding.

Last one is our Source code, what is a source code? here is my explanation, source code is a list of text that contains commands or instruction created by operators in a read-able computer language that needs to be compiled to a machine code then will an executable computer program.The source code of a computer program is specially designed to be a facilites for the work of computer programmers, who then… will specify the actions to be performed by a computer mostly by writing source code.

Now that you understand those 3 parts that consist in OOP, I hope you will be better at coding using OOP programming language, since now you understands its meaning and part.

Conclusion

  • A compiled programming language is a programming language that compiles instruction that the operators write into bytecode or machine language with the help of an IDE.
  •  Bytecode, also known as p-code or a portable code, is a form of instruction that is set and designed for efficient execution by a software interpreter.
  • Java bytecode, bytecode is a set of instruction that is created by the Java virtual machine. Each bytecode is composed from one or two bytes that represents the instruction (p-code).
  • a computer programming language that uses binary or hexadecimal insturction that consist of one and zero(bits) that the computer can responds to directly using it’s central processing unit (cpu)
  • source code is a list of text that contains commands or instruction created by operators in a read-able computer language that needs to be compiled to a machine code then will an executable computer program. 

OOP or Object Oriented Programming

Hello, how are you doing? well i am fine indeed.Last time we talked about each of Java and Javascript pros and cons, both of them had their own advantages and disadvantages, but they’re basically the same.Now we’re going to talk about OOP or Object Oriented Programming, what is its definition, example and stuff. First I apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

What is an Object Oriented Programming? (or we’ll call it OOP just for a shorter instance) OOP is just a programming language that often uses object as its coding bases. If you wanted to be more specific, Object Oriented Programming is a programming language model that is organized around “objects” rather than logic manipulating, OOP takes the view that what we really care is the object that manipulate itself rather than the logic required to manipulate them. It may sounds confusing, so you could just uses the first definition for your beliefs.

What programming language that uses OOP as its base, can you guess? i’ll give a clue, we talk about it in more or less about 3 post, we make a program with it using an IDE. Can you remember now? okay i’ll tell it to you now, it’s Java!! yes, Java is an Object Oriented Programming, just think that we need to make a ball object, a function, method etc… and I’d just tell you in my last post, Java vs Javascript, in there I explained that Java is an Object Oriented Programming language.

What is the basics of Object Oriented Programming or OOP ? well there is actually 10 basics of OOP that I knows, here are the list :

  • Abstraction
  • Class
  • Encapsulation
  • Information hiding
  • Inheritance
  • Interface
  • Messaging
  • Object
  • Polymorphism
  • Procedure

 Let’s talk about 3 of them, which is : Class, Inheritance and Object itself.

First… Class, what is a class?, not that kind of class you go everyday, a Class in Coding, well here is my definition, a Class is a category of objects, a class will contain all of the common properties that belongs to any objects wether it’s different or not.We can also say it in another way, a class is an extensible program-code-template that used to create objects, and could also implements behavior.

Second… an Inheritance, what is an enhiritance?, Just imagine like our world, that every object has something in commong, just for example, a monkey and a human, both of them are a living things, both of them has hands, legs, eyes, ears and mouth, but there is something in someway that seperate a monkey and a human, well it’s called an Inheritance, an Inheritance are the way of some objects will shares similarities like characters but in one if them has some difference, but still inherit something from another object. Well that’s pretty easy right? now let’s move to the last one.

Third… an Object, what does an object means in programming? is it the same definition with the one’s that are in real life? well… an object in a programming language is a particular instance to a “Class” which the object itself can be combination of variables, function and data structures.

What is the advantages that people sees in OOP, One of the most common advantages of object-oriented programming techniques rather than using normal programming techniques is that OOP would allow the programmers to create a somewhat a modules that do not need to be changed over and over again, when a new type of object is added to the program. A programmer can simply create a new object that inherits many of its features or functionality or properties, from existing objects. This makes object-oriented programs easier to modify.

Conclusions :

  •  OOP is a programming language that often uses object as its coding bases or Object Oriented Programming is a programming language model that is organized around “objects” rather than logic manipulating, OOP takes the view that what we really care is the object that manipulate itself rather than the logic required to manipulate them.
  •  Java is an Object Oriented Programming.
  • a Class is a category of objects, a class will contain all of the common properties that belongs to any objects wether it’s different or not
  •  an Inheritance are the way of some objects will shares similarities like characters but in one if them has some difference, but still inherit something from another object.
  • an object in a programming language is a particular instance to a “Class” which the object itself can be combination of variables, function and data structures.
  • The advantages of OOP, A programmer can simply create a new object that inherits many of its features or functionality or properties, from existing objects

Java vs Javascript

Hello, how are you doing? well i am fine indeed.On my last post we just made ourself another version of movingBall program, it’s the same movingBall program but written in different programming language. We made ourself 2 movingBall program, first one in Java and second one in Javascript, well now it’s time for us to take a look at pros and cons from both Java and Javascript. First I apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

First let’s get the definition of both Java and Javascript, Java is an Object Oriented Programming language while Javascript is an Object Oriented Programming Scripting Language. Both of them are an OOP language but there is a difference, Javascript is a OOP scripting language and what does that means? a scripting language is a programming language that supporst script, program written for a special run-time environment that automate the execution of somekind a task that alternatively can be executed one by one with human operator. An environments that can be automated through scripting is, software applications, web pages within browser, and some numerous numbers of games.


Java is a compiled programming language, it is typically written in an Integrated Development Environment (IDE) and compiled into a bytecode, bytecode is not readable for human language and any Java Virtual Machine could run it. Javascript is a programming language that is Interpreted rather than Compiled, an Interpreted programming language is a programming language that execute the instruction directly, without previously compiling it into a machine-language. Javascript may be easier to create because it doesn’t need to be compiled and deployed like Java, Javascript sometimes can be just created by using a simple text editor like notepad++

Both of java and javascript can be runned inside a browser, in modern browser they obviously take advantages to enhance’s the users experience.Java applet can also be runned in browser, but it have been declining in it’s popularity for various of reasons, first it’s compatibility issues even to security reasons. It is been widely common for a website visitors that it’s javascript is enabled and it is also widely common for a website visitors that it’s Java applet is disabled, especially in mobile browsers.

In javascript you need to send it to the internet first or to your browser first to get the program works, but Java can create a standalone application that doesn’t need any other intermediary to run it, it works on it own. The standalone application is called a Java “applet” (so-called like that because it is a little application) that is a fully contained program. While javascript can only be runned in Javascript with the help of Html and CSS.

Each of them had their own pros and cons, you should pick one programming language that suites you heart, the one that you get comfortable with. Well you could learn both of them but after that choose one that you’ll go deeper with.

Conclusions:

  • Java is an Object Oriented Programming language
  • Javascript is an Object Oriented Programming Scripting Language
  • a scripting language is a programming language that supporst script, program written for a special run-time environment that automate the execution of somekind a task that alternatively can be executed one by one with human operator.
  • Java is a compiled programming language
  • Javascript is a programming language that is Interpreted
  • A compiled programming language is a language that compiles codes into machine-language
  • Both of java and javascript can be runned inside a browser
  • Java can create a standalone application that doesn’t need any other intermediary to run it

MovingBall in Javascript

Hello, how are you doing? well i am fine indeed.In my last post we get our brain and finger exercised on Javascript, we did our exercise in Chrome development console well it’s just for an exercise, but today we’ll do some real Javascript coding, we’ll simply make a Movingball program just like in Java.The way to do this is we need to make a Html file that contains javascript, so let’s do that right now.  first I apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

First we need to make an HTML file, you can do this in the notepad++ it can be freely downloaded, now let’s make the structure of the Html, since we don’t really talk about Html much in this blog i’m just going to give you the important Html code structure which looks like this, the canvas is just how big that we want  the background of the painting will be, so don’t worry:


<!DOCTYPE html>
<head> 
<title>MovingBall</title>
</head>

<body>
    <canvas id=”canvas” width =”700″ height=”700″></canvas>
    <script> 

                  /*the section that
                 
we’ll write some Javascript in it*/

    </script>
</body>
</html>

 you just need to write this inside the notepad++ and save as Ball.html (you could name it whatever you want, as long it ends with .html) now after you save that as Ball.html  you will see some changes that is applied to your code, now it has colors right it’s just a helping technique that will help programmer write their code more efficient and more easy.

Now after we finished with the html, let’s work some javascript! the structure prototype and function of this MovingBall is a lot similar with the one that we did with Java, but this one is going to be more easy because it doesn’t have variable typing and class that needs to be created etc… so let’s write it inside the
<script></script>:
first we’re going to make the ball object or ball prototype :
  var Ball = function() {
    this.x = 100;
    this.y = 100;
    this.xSpeed = -5;
    this.ySpeed = 6;
    this.border = 10;
    };

after this we’re going to create a function that will draw a circle whenever it’s called or executed, this is how we write it:
  var circle = function(x, y, radius, fillCircle){
        ctx.beginPath();
        ctx.arc(x, y, radius, 0, Math.PI * 2, false);
        if (fillCircle) {
            ctx.fill();
        } else {
            ctx.stroke();
        }
    };

good now we have created a circle function, now let’s add some more function for our ball, just like draw, move and checkCollisions :
    Ball.prototype.draw = function(){
        circle(this.x, this.y, 20, true);
    };
   
    Ball.prototype.move = function(){
        this.x += this.xSpeed;
        this.y += this.ySpeed;
    };
   
    Ball.prototype.checkCollision = function() {
        if (this.x < 0 + this.border || this.x > 700 – this.border) {
        this.xSpeed = -this.xSpeed;
    }
        if (this.y < 0 + this.border || this.y > 700 – this.border) {
        this.ySpeed = -this.ySpeed;
    }
    }

you see it’s not that different than what we write in our Java coding right? so this will be pretty much easy. Do you have any clue for what we need to write next? we’ll since we’re in javascript environtment inside html inside a browser (yeah right! we’re going to run it in a browser) we need to call a chunk of code that will get the 2d context for the program and this is how we do it:
    var canvas = document.getElementById(“canvas”);
    var ctx = canvas.getContext(“2d”);

 after we create the canvas and context environtment now we’re going to call the ball object or ball prototype and after that we paint or call everybit of code in this program repeatedly over and over, so we write it like this:
 var ball = new Ball(); //we call the ball object or prototype
   
    setInterval(function () {
        ctx.clearRect(0, 0, 700, 700); //we clear the background
        
        ball.draw();
        ball.move();
        ball.checkCollision();
      
        ctx.strokeRect(0, 0, 700, 700); //we create a stroke for the background
        ctx.
        ctx.fillRect(350, 350, 40, 40); //we create a white background
    }, 30);

And you need to remember that you need to write this inside the <script></script> tags or it will never work.
Now, the way you run it is you go to the location of you saved Ball.html, now right click on Ball.html and select open with>(you can choose any browser, but i recommend using firefox or chrome) then… tada!!!! you just make a moving bouncing ball in javascript inside html inside a browser, fun right this may seems much easier for you to understand rather than Java that is a strong typed language, well javascript is easier but each of them had their own advantage and disadvantages just find which one you’re comfortable with.

Javascript Warm Up

Hello, how are you doing? well i am fine indeed.In my last post we talk about Javascript, its history, the guy who made it, what is its used for, “var” and more. We also use Javascript to make our web browsing more unique by implementing animation and rendering, which is very cool and we also could do things like that if we learn Javascript. Now, we’re going to exercise JS or JavaScript, first I apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

First we need to find a place to learn our javascript, and luckily Chrome serves us right! Chrome implemented a development console in the browser to do JS stuff, well firefox also did implement development console but lets just use chrome for the sake facility. Now, open your chrome and go to a blank page, if you don’t know how you just type about:blank in the address bar, well this is only optional but it’s easier to just see blank page first when writing our code, now let’s get to writing part!.


Now we got that sorted out let’s write some javascript! now you need to open the development console in the chrome, if you don’t know how this is how you do it, first open the google chrome control menu –> hover you mouse to more tools –> click development tools. That’s the long way to open the development  console, for simplicity sake just use Ctrl+Shift+I, got you! (haha). Now for a warm up, let’s just write the most simplest code that we’ll write today, just type 1 + 1 you don’t need to put an equal( = ) sign, just do that and hit ENTER and… that’s it you just write a succesful piece of code(By the way it should output the number 2). You may try to even billions of number calculating but the computer will always answer as long as you put the syntax right.


Remember when I say javascript is an Untyped programming language, it means that we could use “var” variables for any type of data we want, we could put number inside it, text, commas, special character etc… so if you want to make a position of an object that is keep changing you could use the “var” variable, for example ” var x1 = 200 ” as position 1 and we need to make it move 100 pixels to the right and we make a variable for that too ” var x2 = 200 ” and what we need to do is add those 2 variables together, so we do this “ x1 + x2 ” and it will output 400, it’s just the same when we calculate just the number only, like 200 + 200 but in this case we use the variable to keep track of the numbers that is keep changing.

Well it’s quite easy isn’t it?! it’s just a tini tiny part of code that you can write in javascript, now let’s move to a bit more advanced javascript coding, let’s output your name into the console of javascript world, first you make a variable called “name” and inside that variable you put your name in a string type, it should look like this ” var myName = “you’re name”; ” well it wouldn’t output anything at the moment but it’s just the shell for our next code. After that lets output our name to the world, type this in the console  myName + ” is awesome”; ” (you could put anything inside that string), here what it would output if I do it with my own name :
Rafif is awesome
tada! we made it isn’t it fun, (tell me how you did it with your own name).

Now let’s get to a more complex piece of code, we’ll output our name to the console 10 times automatically without human help, what do I mean without human help? it means that when we execute the code the computer will automatically outpute 10 of the requested output, so lets do that right now!. first you make your name variable just like before, second we’ll make a function that will output the information of our variable for 10 times, here is how we create the function:

var myName = function (howMany) {
for (var i = 0; i < howMany; i++) {
console.log( i + name + ” is awesome”);
}
};

after we create the function it’s time to execute or call the function!:

myName(10);

tada! you just make another piece of working code, by the way this is how my output looks like :

0Rafif is awesome
1Rafif is awesome
2Rafif is awesome
3Rafif is awesome
4Rafif is awesome
5Rafif is awesome
6Rafif is awesome
7Rafif is awesome
8Rafif is awesome
9Rafif is awesome

In javascript you could make such many other things, not only number calculating but you can make an animation or even a game! wooww! cool right? you could do such things like that if you learn it and understand it, and by it I mean javascript, so keep learning!.

Javascript

Hello, how are you doing? well i am fine indeed.In my last post we talk about an IDE, what is its definition, what is its used for, example for an IDE and more. We also use an IDE to make our MovingBall program, which is very cool and its very helpful for new coders. Now, we’re going to talk about JS or JavaScript, first i apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

(The history of Javascript, Javascript was created in 10 days in May 1995 by Brendan Eich, you know… that Javascript wasn’t the first name that is used for this language, first time it was mocha and  in September of 1995 the name was changed to LiveScript, then in December of the same year, upon receiving a trademark license from Sun, the name JavaScript was adopted. This was somekind of a marketing move at the time, and because that Java being very popular programming language around then.) 

Since we talk a lot about Java, Javascript feeling a little bit lonely, but now the time has come for us to know Javascript.First, what is Javascript? for the most simple explanation, javascript is a programming language, just like java. Now for the long explanation, my understanding of javascript is, “a high-level, untyped programming language that is widely used for major web browser“alongside with the HTML and CSS, it is one of the three core programming language that is used for the technologies of world wide web.

Now let me explain this little by little, first javascript is a high-level programming language just like Java so what does this means? a high-level programming language is a programming language that is more closer to human language and further from the machine language so this makes the coder jobs easier because it is using a  language that is more understandable by human brain. Next one is the “untyped“, what does untyped means? of course it doesn’t means that you don’t need to type it to the computer but it means that, not like Java… Javascript does not use typing for its language, perhaps the word typing is familiar to you, well I already told you in my previous post (Java Variables) that Java is a strongly typed language this means that any data needs to be stored in the right variables, like Integer for number, String for words, and double for numbers that contains decimal.Well javascript doesn’t use that kind of thing, it only uses one variable for all kind of data which is “var” variable, it is a    for variables, right? did you catch that before me? so that is what it means to be an untyped programming language.

Javascript is widely used by the web, because it is the only scripting language that is supported by every major web browser approved by  ECMA(Internet Explorer, Firefox, Chrome, Netscape, Safari, Opera, Camino, etc). Moving on to the next thing, why do I say HTML, CSS and Javascript is the three core for world wide web? just see that everything you see in this page in you browser is made by those 3 programming language, can you guess what language do what? if you don’t let me tell you, first… can you see text inside the pages you see (of course right? or maybe the text is readed to you) well the text that you see is made by the HTML language, HTML is used to make any kind of text, second… can you see color or text style in this page? well CSS is the one that made such a thing, CSS is used to style a page, and now…. do you see a scrollbar in your page?(if you didn’t see it in this page try to go to a page that contains a lot of text)can you scroll it up and down?of course, and that thing uses Javascript to make it, Javascript is used to render or animate things.

You see those three programming language to be the structure to make web pages. Without one of those programming language a web page would be boring and not interesting, so if you want to make a web page make sure that you have all those 3 programming language implemented in your web page.

Conclusions

  • Javascript is “a high-level, untyped programming language that is widely used for major web browser”.
  • HTML, CSS and Javascript are the three core of world wide web.
  • A high-level programming language is a programming language that is more closer to human language and further from the machine language.
  • Javascript only uses one variable for all kind of data which is “var” variable so its considered to be an untyped programming language.
  • Javascript is the only scripting language that is supported by every major web browser approved by  ECMA

What is an IDE ?

Hello, how are you doing? well i am fine indeed.In my last post we make our way to create a program which is called a MovingBall, which is a program that makes a ball moves accross the screen and it could bounce off the side of the program and that is very cool and to make that program we use an IDE the IDE is called netbeans. Now, we’re going to talk about IDE, first i apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin.

First, we need to know what an IDE is, and why is it created. well in my understanding, an IDE is a software application that provides the computer with facilities for computer programming or software development, it contains a code editor or a compiler that the user acces through a single GUI (graphical user interface). It is created for computer programmers and software developers because it has a compiler or code editor that helps coding syntax, what do I mean by help? well simply it could add a sugestion on what you’re going to type and this is very helpful for a beginner coder because we don’t need to search the internet or read books and do other complicated things, it will automatically add sugestion on what we’re suppose to type or what we want to type, an IDE will serves developing environment on one or multiple coding language.

You might ask, what is the functionality of an IDE? Just like I say before it has a compiler of code editor that helps coding syntax and there are many common features that is created in an IDE, such as debugging code or program and data structure browser etc… this is  very helpful for its user because it can make a user quickly execute an action without needing to go to another application so that help maximize the productivity of coding with the help of its GUI (graphical user interface) and UI (user interface).

what is an example of an IDE? there are 2 IDEs that i know, first one is Netbeans and the second one is Java Eclipse. each of them serves the developing environment with their own way but you’ll find it very similar in some way. if you want to check it out here is the link : Netbeans and Java Eclipse. You may try both of them at first, but as you feel more comfortable with an IDE you should choose one of them to avoid complicated problem when you switch from one to another ID, you should choose the one that you thinks more comfortable and you feel good with it.

here are 2 footages of both Netbeans and Java Eclipse:

Netbeans
Java Eclipse

  

 conclusions

  • an IDE is a software application that provides the computer with facilities for computer programming or software development, it contains a code editor or a compiler that the user acces through a single GUI (graphical user interface).
  • an IDE has a compiler or code editor that helps coding syntax.
  • an IDE will serves developing environment on one or multiple coding language.
  • common features in an IDE : debugging code or program and data structure browser etc…
  • an IDE makes a developer quickly execute an action without needing to go to another application so that help maximize the productivity of coding with the help of its GUI and UI.

Make a MovingBall in Java, Part 2

Hello, how are you doing? well i am fine indeed. Today we’re going to continue our exercise making a ball move in Java, well on the last post we manage to make a frame for the ball to move, today we’re going to make the ball “move”. before we begin, first i apologize if there is any mistake, any help or knowledge would be nice. Lets be done with the chit-chat and lets begin!


So, first you need to have netbeans if you don’t you can download it here: Netbeans. and you need to install a minimum of JDK 1.7.0, you can download it here: JDK. If everything is set to go, now you open your netbeans. lets continue from our last post which is this:

Make a method that paints an object in the program
Paint method

now the most important thing on this program is to have a ball moving on the screen righ? because we’re making MovingBall program, so to make a ball moving on the screen we need to make a method, a method is a piece or a chunk of code that will execute when you call upon it, now you put ball.moveBall(); before the “ball.repaint();” the reason that we put ball. before the method because it’s for the ball object. at first it’s going to give you an error, you see that little lightbulb thing with red warning that means it is an error, why?? it’s because you haven’t created the method yet, what you did is you call the method without making it first, understand?? now let’s make the method, you need to write this :
public void moveBall()
{
       

} 

you write it before the paint method, and it should look like this:

now the most importand thing is to draw the ball, we need to draw the ball in a method, can you guess what method we should use to draw the ball? correct, the paint method. Now you might ask “why didn’t we use the moveBall method instead?” well the moveBall method is a method to make the ball “move” and not to draw the ball, instead paint method is a method to draw an object, since logically “paint”, duhh!.

here is the all the code you need to write to draw a ball : public class MovingBall extends JPanel{
   
    int x = 0;
    int y = 0;
   

    int diameter = 30;   

    public void moveBall()
    {
   
    }
   
    @Override
    public void paint(Graphics g)
    {
        super.paint(g);
       
        g.fillOval(x, y, diameter, diameter);
    }

 and when you run it is should look like this:

congratulations, you just draw a ball in a screen, cool!!.
now let me explain the steps that is needed to draw a ball like that.First we need to make a variable that contains the positions of the ball and the diameter of the ball, second we draw the ball.Now, I already explain what is variable in my other post, chek it out: Variables. Specifically we need to make an integer variable, for what you might ask, well it’s to determine the ball position.
“well why didn’t we determine the position with whole number when we draw the ball in this line  “g.fillOval(x, y, 30, 30);” ” you could use a whole number like 0, 1, or 2 to determine the position, but consider this, what program are you making? does the ball move or it doesn’t? if the ball moves we need to make a variable to store the position of the ball, because!! the position keeps changing automatically, there is no way you could do it without a variable that store the position of the ball. Now that the problem is settled, lets continue, now we need to make the ball move. Just like I say “the position keeps changing automatically”, we need to make the ball move on itself, the way to do is pretty easy its just two line of code which is:     int x = 0;
    int y = 0;
    int diameter = 30;


    public void moveBall()
    {
        x++;//this line
        y++;
//and this line

    }
   
    @Override
    public void paint(Graphics g)
    {
        super.paint(g);
       
        g.fillOval(x, y, diameter, diameter);
    }

can’t do images because the ball wouldn’t move, lol.

then you run it! well done *clap, clap* you just make a ball move! great right? now there is one problem, can you tell? the ball move through the side of the program! Grrahhh. we really really need to fix this problem!. now we need to create a barier, we write this in the code. We somehow need to calculate, when the ball hit a side of the program it should come back with different velocity. we can do it like this:  int x = 0;
    int y = 0;
  
    int diameter = 30;
  
    boolean moveDown = true;
//if we didn’t create this the ball will never bounce back because the
                                                  previous velocity will still be applied
     boolean moveRight = true;//if we didn’t create this the ball will never bounce back because the
                                                   previous velocity will still be applied
  
    public void moveBall()
    {
        if(x == getWidth() – diameter)
        {

              moveRight = false;  //if the x of the ball hit the right side of the program then moveRight
                                                 is false this will make it move to the left
        }
        else if(y == getHeight() – diameter)
        {
              moveDown = false;
//if the y of the ball hit the right side of the program then moveDown
                                                 is false this will make it move Up
        }

        }
      
        if(x == 0)
        {
        
          moveRight = true; 
//it’s just the same with the one above but it’s flipped to it’s original situation

        }
        else if(y == 0)
        {
              moveDown = true; 
//it’s just the same with the one above but it’s flipped to it’s original situation 
        }
      
        if(moveDown)
        {
         y++;
//this situation is if moveDown is true, then, y position will be moved 1 pixels each frame/time;
        }
        else if(!moveDown)
        {
         y–;
//this situation is if moveDown is false, then, y position will be moved1 pixels backwards each
                  frame/time
        }
      
        if(moveRight)
        {
         x++; 
//this situation is if moveRight is true, then, x position will be moved 1 pixels each frame/time; 
        }
        else if(!moveRight)
        {
         x–;
//this situation is if moveRight is false, then, x position will be moved 1 pixels backwards each
                 frame/time
 }

    }

after you write that on you program codes, you run ! BOOM!! you have a fully working moving, bouncing ball program in Java, congrats!.
After this exercise I hope you will get more comfortable and will more understand the Java world of Coding We have finished our exercise, so see you in another post!.

See part 1