<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Armen</title>
    <description>The latest articles on DEV Community by Armen (@armen_mesropyan).</description>
    <link>https://dev.to/armen_mesropyan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1159566%2F9c2dc8fe-3da0-4312-be8a-9e317ca463c0.png</url>
      <title>DEV Community: Armen</title>
      <link>https://dev.to/armen_mesropyan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/armen_mesropyan"/>
    <language>en</language>
    <item>
      <title>Small journey into the world of Java</title>
      <dc:creator>Armen</dc:creator>
      <pubDate>Tue, 28 Nov 2023 16:21:54 +0000</pubDate>
      <link>https://dev.to/armen_mesropyan/small-journey-into-the-world-of-java-ebc</link>
      <guid>https://dev.to/armen_mesropyan/small-journey-into-the-world-of-java-ebc</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java is a high-level, class-based, object-oriented programming language designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once and run anywhere, meaning that compiled Java code can run on all platforms that support Java without recompiling. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fundamentals of Java&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What do I mean by saying compiled Java code? Imagine you have a friend who speaks English, and you speak French. You want to give them a message. You write the message in French, and your friend translates it into English so he can understand. When you write a Java program, it is not yet something that the computer can run directly. It needs a translator, and that’s where the JVM (Java Virtual Machine) comes in. The JVM is like the friend who translates your Java code into something the computer can understand. This process is called compilation. It’s like taking your message in French and turning it into English, so your friend can understand. In Java, we use a special program called a “compiler” to do this. The compiler takes the human-readable Java code and turns it into Bytecode. Now, bytecode is like a universal language that the JVM understands. It’s not specific to any computer or operating system. It’s like turning your English message into a language that people can understand worldwide. Once the bytecode is ready, the JVM takes this bytecode and translates it into instructions that the computer can execute. After this, if a proper JVM is installed on the computer, any Java bytecode can be run. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8is43jkocd05vt2hz9r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8is43jkocd05vt2hz9r.png" alt="Java compilation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types in Java&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Java, several types can be used to define different kinds of data. Here are some of the main types in Java:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Primitive Types:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;int:&lt;/strong&gt; Represents integers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;long:&lt;/strong&gt; Represents long numbers (has a very big range)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;float:&lt;/strong&gt; Represents about 6 decimal digits&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;double:&lt;/strong&gt; Represents about 15 decimal digits&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;byte:&lt;/strong&gt; Represents a very small number (from -128 to 127)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;short:&lt;/strong&gt; Represents a small number (from -32,768 to 32767)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;char:&lt;/strong&gt; Represents single character&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;boolean:&lt;/strong&gt; Represents true or false values&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Reference Types or Non-primitive Types:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;String:&lt;/strong&gt; Represents a sequence of characters (text)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Array:&lt;/strong&gt; Represents a collection of indexed elements of the same type&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Class:&lt;/strong&gt; Represents a blueprint for creating objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interface:&lt;/strong&gt; Represents a collection of abstract methods&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Custom Types (User-defined):&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can create your own types using classes and interfaces&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F040k8vk6njvdtzz527ei.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F040k8vk6njvdtzz527ei.png" alt="Types in Java"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Differences between primitive and non-primitive types&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The main differences between primitive and non-primitive data types are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Primitive types are predefined in Java. Non-primitive types are created by the programmer and are not defined by Java (except for String).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Non-primitive types can be used to call methods to perform certain operations, while primitive types cannot.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A primitive type always has a value, while non-primitive types can be null.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A primitive type starts with a lowercase letter, while non-primitive types starts with an uppercase letter.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyiuuqo46pdtsk1jqwgip.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyiuuqo46pdtsk1jqwgip.png" alt="Difference of data types"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OOP (Object-Oriented Programming)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As the name suggests, Object-Oriented Programming or OOP refers to languages that use objects in programming, they use objects as a primary source to implement what is to happen in the code. Object means a real-world entity such as a pen, car, or computer. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function. OOP simplifies software development and maintenance by providing some concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Encapsulation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Abstraction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inheritance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Polymorphism&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These concepts are called “4 pillars of OOP”. Now, let's understand what these concepts are and how they work. &lt;br&gt;
Firstly, encapsulation in Java is a process of wrapping code and data into a single unit; for example, in the real world, a car is an object, right? When we park the car in the garage and close it, that’s encapsulation. In Java, we can create a fully encapsulated class by making all the data members of the class private. &lt;br&gt;
Secondly, abstraction in Java hides the implementation details and shows only functionality to the user. In the real world, think of a DVD player as an object. This DVD player has a complex logic board inside and only a few buttons outside that we interact with. We press the play button and don’t even care what happens inside. All that complexity is hidden from us. This is an abstraction. &lt;br&gt;
Thirdly, inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. The idea behind inheritance in Java is that you can create new classes built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can add new methods and fields in your current class.&lt;br&gt;
Lastly, polymorphism in Java is a concept by which we can perform a single action differently. Polymorphism is derived from 2 Greek words: poly and morphs. The word "poly" means many, and "morphs" means forms. So polymorphism means many forms. There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism. We can perform polymorphism in Java by method overloading and method overriding. &lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Introduction to the world of numbers in computers</title>
      <dc:creator>Armen</dc:creator>
      <pubDate>Tue, 12 Sep 2023 21:07:19 +0000</pubDate>
      <link>https://dev.to/armen_mesropyan/introduction-to-the-world-of-numbers-in-computers-4llg</link>
      <guid>https://dev.to/armen_mesropyan/introduction-to-the-world-of-numbers-in-computers-4llg</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Surely, many of you wondered how a small computer or any other technological device works. It is really fascinating when you start to understand the principles behind computers. Basically, computers do what people tell them to do. But, how? Do they understand human language? This is a question I believe everyone asked themselves at some point of life. And the answer is very simple: NO, computers do not understand human language. So, there is another logic that computers use in order to communicate with humans or with each other. Modern computers use electricity to work and inside a microchip the electricity is either switched on or off. The existence of electricity is represented by 1 and 0 which is called the binary number system. So, computers understand us because whatever we write in it, it converts the input into binary numbers and understands it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The idea of different number representations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are many numerical systems such as the one that we use, the decimal system or base 10. Since we have only 10 fingers, there are 10 digits that we use to represent any number. But this does not mean that there cannot be a numerical system that has more than 10 symbols. In fact, there are base 11, base 12, base 16 and so on. In order to represent a number in base 16, after the digit 9, as we have no more digits, we start to use letters (A, B, C, etc.). For example, the number 2 in decimal is just 2, but in binary we do not have the symbol “2” so we write 10 which is not “ten”, it is “one and zero”. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K-8oh8S2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34ha3u83nfy6y6x9v8xc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K-8oh8S2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34ha3u83nfy6y6x9v8xc.jpg" alt="The corresponding binary number for its decimal" width="316" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conversions between different number representations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, how do we know the corresponding binary number for its decimal or vice versa. Look at the picture below. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zvh_escV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3adxotarc7tqf5gkjyvj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zvh_escV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3adxotarc7tqf5gkjyvj.jpg" alt="Conversions from decimal to binary" width="400" height="317"&gt;&lt;/a&gt;&lt;br&gt;
In this picture we want to convert the decimal number 25 to binary number. For that, we will use the simple mathematical division method. Since we want to convert it into base 2, we need to divide 25 by 2. 25 is not divisible by 2, so we write 12 and the remainder 1. Then, we should divide 12 by 2. Here, 12 is divisible by 2 so we have 0 remainder which we must write too. So, by using this principle we divide decimal numbers by 2 and write remainders. In the end we should write the remainders in reverse order and BOOM!! We have the corresponding binary number for 25 which is 11001. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In order to convert the binary number into decimal we need to write the binary number and start to count it starting from the end and from 0 (Check out the picture below). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8gt-6_a3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u35m8xmcssl9vfsmauf8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8gt-6_a3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u35m8xmcssl9vfsmauf8.png" alt="Conversions from binary to decimal" width="448" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, the counted numbers we need to use as the power of 2 (because we are in base 2). For the first cell we write 2^0 and multiply this by 0 because we have 0 inside the cell. For the second cell we write 2^1 and multiply this by 1 because here we have 1 inside the cell. We keep doing this till the last cell and start to count the results for each cell. After that we add them together and get the decimal number (here 42).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can use the exact same method to convert any number into any numerical system. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Addition,  subtraction, multiplication and division of binary numbers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Like in the decimal system, in binary too, we can do basic arithmetic operations with numbers such as addition, multiplication, etc. In order to do that we should again use the same rules and methods as usual. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The picture below shows the operation of adding two binary numbers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B3qV3S5T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8u716ayburb1609fol4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B3qV3S5T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8u716ayburb1609fol4.gif" alt="Addition of binary numbers" width="385" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to simplify our work a little, we can think like this: if we want to add the binary 1 by 1, we can do their addition in decimal (in mind), the result is 2, right? What is the binary number for 2? Yeah, you are right, it is 10. So, 1+1 in binary is equal to 10. This method is very helpful especially when we need to work with big numbers when we need to add four or five “1”. In that case, in decimal 1+1+1+1 = 4, in binary 4 = 100, so, 1+1+1+1 = 100. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiplication of binary numbers is very simple because there is nothing new to tell. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pP8HdO7R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ljvgy7lvptxk5ou9hhu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pP8HdO7R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ljvgy7lvptxk5ou9hhu.png" alt="Multiplication of binary numbers" width="396" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At first we need to do the multiplication of zeros and ones, the exact way that we would do in decimal, then, we need to do the additions and we are done.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Subtraction is a bit harder to understand compared to multiplication. Again, the same rules of usual subtraction apply here. When we add two binary numbers we put the carry at the left column and then continue to add using that carry. In case of subtraction, when we cannot subtract 1 from 0 we borrow 1 from the left column (if there is 1, if not we keep going left till we find 1). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BhygAACK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzh7mqz04r2813x31teg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BhygAACK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzh7mqz04r2813x31teg.jpg" alt="Subtraction of binary numbers" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, in this picture, in the first column we need to subtract 1 from 0, so we borrow one from the left column, so the first column becomes two ones (1, 1). Subtracting 1 from 2 we get 1 and go on. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Division of binary numbers is the most difficult arithmetic operation compared to others. Usual rules and methods do apply here. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jJ4cQ-gP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0zvfnb8ywoek4cen5zd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jJ4cQ-gP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0zvfnb8ywoek4cen5zd.png" alt="Division of binary numbers" width="270" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, the number 10010 is the dividend and the number 11 is divisor. At first we need to find a part in number 10010 that starts from that part the number is greater than 11. In this case, 1 is not greater than 11, 10 also, but 100 is already greater than 11 so we start by dividing 100 by 11. How many 11 we have in 100? Again, it is a good idea to do decimal divisions in mind. Since we have one 11 in 100, we write 1 above and start to do subtraction.  By doing the simple operations here we get the answer 11. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Important advice: 
 It is always a good idea to double check the answers in 
 decimal form.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Negative binary numbers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since in base 2 we have only two symbols 1 and 0, we cannot represent -1 by adding a minus sign in front of the number. So, we need to represent negative binary numbers by putting an extra byte which contains either 0 for positive number or 1 for negative number. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xgoRJpBk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m8wbtidgc26hichluzd1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xgoRJpBk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m8wbtidgc26hichluzd1.png" alt="Negative binary numbers" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
  </channel>
</rss>
