Skip to main content

Posts

Showing posts from 2021

Launch multiple programs with one shortcut in Windows Operating System

  Yes...!! you heard is right 😊and it’s possible with simple coded steps. When we’re getting into a Daily work, we’ve to deal with many Tools, Editors, Folders and Files. Opening of all these on daily basis is a tedious job 😖. In My Scenario, daily I’ve to open multiple chrome browsers, project folders, files and visual studio to continue my regular project tasks. To mitigate this, I am bringing up this article for you Just by writing simple coded steps in a Notepad/any editor to overcome this. Write below code in notepad and click on File->Save As -> Give your name followed by .bat  extension and click on OK button. Now your shortcut key is ready. Just double click it and have fun with it. Below is the code: @echo off :: Open folders start %USERPROFILE%\Documents\ start %USERPROFILE%\Desktop\Test\ :: Open files start "" "%USERPROFILE%\Desktop\DeskTop\SM\test.txt" ::Open browser start chrome.exe start " " https://www.freecodecamp.org/learn...

Difference Between Programming and Coding

What exactly is the difference between programming and coding?  The other day, one of my friends who is not from a computer science background, asked me this question. Even after learning many different programming languages and doing several projects, I could not answer him correctly. I said both are the same. But why do we use two different terms, if both are the same? That led me to some research, and I thought I’d share what I found.   It’s not that complicated.  And their definitions allow for a lot of overlap. We often recognize the terms coding and programming as synonymous because both are often used interchangeably.   what is the difference between programming and coding? Coding is the act of expressing programmatic ideas in computer language. Programming is crafting ideas that can be executed repeatedly by a machine, not necessarily a computing device. While both the terms are synonymous with each other and are often used interchangeably, t...

Type Conversion

  Operations in our applications will commonly involve multiple data types. Because of that, we must deal with type conversions. Now there are implicit type conversions, and those are type conversions that are performed automatically by the compiler. To see a simple example of that, we look at something like here we have an integer iVal that we've assigned the value 50. If I then say long lVal equals iVal, the compiler must convert that 32 ‑ bit integer iVal into a 64 ‑ bit integer as it's stored into lVal. And there are also explicit type conversions, and these are conversions that I explicitly perform in my code and I do that using a cast operator. We see here if I had that long lVal = 50 now, so I'm now assigning a 64 ‑ bit integer the value of 50, if I want to assign that into this iVal, a 32 ‑ bit integer, I have to explicitly cast it. I must tell part of that I want to go from that 64 ‑ bit integer into a 32 ‑ bit integer. And I do that by using the type I want to con...

Operator Precedence

  The operators are evaluated in a well ‑ defined order. If we look at them, basically, the postfix operators are evaluated first, then prefix operators. Then the multiplicative operations, all right, multiplication, division, and modulus. And then finally, the additive operations, right, plus and minus. Operates of equal precedence are evaluated from the left side of the equation, moving right. And you can override precedents by using parentheses. If you have nested parentheses, those parentheses are evaluated from the inside out.   Demo: Operator Precedence

Arithmetic Operators

  Something we commonly must do in our programs is perform arithmetic operations. Java provides three basic categories of operators for performing math operations. They're the basic operators, like add, subtract, multiply, and divide, what are called prefix and postfix operators, and then what are called compound assignment operators. The basic math operators are just what you would expect, things like add, subtract, multiply, and divide. The operators we use for these are, again, things that are very familiar. If I'm adding, I use a plus sign. And when I do things like add, it doesn't really matter whether I'm using a floating point or an integer. So, if I say 1 + 2, the answer is going to be 3. For subtraction, we use the minus sign. Again, it doesn't really matter whether we're using floating point or integers. If I subtract 4 from 5, I get 1. If we multiply, we use an asterisk, 4 * 2 is 8. And all that stuff is straightforward. As we get to the divide operat...

Primitive Types are Stored By-value

  Java primitive types are stored by value, and that's important to understand because it affects the behaviour applications when we assign values from one variable to another. Let's look here. If I declare an initial variable called firstValue and I assign the value 100 to it, what's happening under the covers is that an area of memory is being allocated that's named firstValue and the value 100 is stored inside that memory. So now if I declare another variable, in this case, other value when I assign first value to it, again, I'm looking in an area of storage, I'm giving it a name otherValue, and when I make the assignment, the value 100 is being copied from firstValue into otherValue. And what that means is that there is a distinctly separate copy of that value 100 being moved over into otherValue. What that allows me to do then is that if I make modifications to firstValue, for example, assign the value 50 to it, that 50 replaces what's in firstValue, bu...

Primitive Data Types

  So, as we've seen when we declare our variables, we give them a type, and the most fundamental types in Java are what are called primitive data types, and these are the data types that are built into the language. Now, when you hear the term primitive data type, you may think there's something kind of lowly about them, you know, something kind of, you know, less than modern about them. But that's not true at all. Primitive data types are actually very important. They're really the foundation of all other types that we use in Java, so they're really that kind of strong foundation that we're going to build on for any other data types we use in our programs. Now there are four categories of primitive types in Java. There are the integer types, floating point, character, and Boolean. So, let's look first at the integer types. Now there are four different integer types, but the difference then really is just the size of storage that they take up. But that diffe...

Variables, Data Types and Math Operations

  In order to do anything interesting in a program, we must have the ability to store and manipulate values. What allows us to do that are what we call variables. Now a variable, simply put, is just named data storage. Now Java is a strongly ‑ typed language. Now what that means is that when we declare a variable like, in this case, we have a variable named data Value, we have to specify the type of that variable, in this case, it's what we call an int, something that can store integers. So, what that means is that the data Value variable can only store things that are compatible with the type int. As we go through the course, we'll talk about this idea of one type being compatible with another. Now when we declare a variable, we can, of course, then assign a value to it, so our variable data Value now holds the value 100. Now when we use variables, we can do it the way we've done here where we declare it, then assign it, or as a matter of convenience, we can declare them a...

Introduction to Packages

Let's talk briefly about Java packages. Now packages are a very important concept in Java, and we can talk a great deal more about them later. We have a whole module dedicated to them. I want to look at just a couple of simple things about packages right now to get us started. Now, if we look at our source code, all the source code we've written up until now has just kind of our class definitions, and that's kind of by itself. But if you look at most Java source code out there, you'll see that at the top of the source code files is the word package, followed by some name, and what this does when we add this package concept is it provides organization within a Java program. Now, again, there're a lot of aspects of that, but I want to look at just kind of two basic aspects of it to get us started. One is that these package names follow a standard naming convention, and they affect our source code file structure. Now in terms of the naming convention, one very simple r...

Comments

  Java, like most programming languages, can include comments. All right, and comments are just basically text inside of your source code that the compiler doesn't see. Right, and there are really kind of just two general uses for comments. One is that it allows you to add human readable notes to your source code, right, it allows you to type things in the source code so that when you look at it later, or someone else looks at it, it's just leaving notes to understand what you were doing there. It's also useful for hiding source cool without deleting it. Maybe you're testing things out, so you want to just kind of take some things away and type some new stuff, or if there's something you don't want to anymore, but you think you want to do it again in the future, so comments allow you to take that stuff out so the content is in your source code, but the compiler doesn't compile it. There are three types of comments in Java. One, which is called line comments,...

Statement Structure and Whitespace

  Java programs are made up of statements. Now, a lot of different things can go on in a statement, and we'll talk about those things throughout this course, but fundamentally, programs are made with statements. Now each statement ends with a semicolon. Java is a language where the newline and the Enter key doesn't really create a new statement. It relies instead on the semicolon. If you're going from any of the C ‑ based languages, that's something you're very familiar with. Other languages like Visual Basic use the end of line to mark a statement. In Java, it's the semicolon. And the parts of a statement can be separated by zero or more whitespaces, and a whitespace could be many different things. It can be the space character, it can be a tab. And because statements don't end with newline, even the newline itself is just a whitespace in Java. Java's a language that gives us a lot of flexibility with whitespaces, so remember we said that the parts coul...

Integrated Development Environments (IDE)

If you wanted to, you could build your Java applications having only installed the JDK. You could use some arbitrary text editor to type in your program code, and then you could use command line tools to do all the compiling and executing of your programs, and that would work fine, and people did that for years, and some people still do that, but in general when we're developing, we want to use a more productive model than that. We like these things called integrated development environments that allow us to type in our code, compile it, debug it, everything all in one place. Now Java has lots and lots of IDEs available, and two of those you'll most commonly hear about are NetBeans and IntelliJ, both of which are available for free. For many years, NetBeans was maintained by the Oracle Corporation, and when Oracle was maintaining it, it was the official IDE for Java development. But Oracle support for NetBeans stopped as of JDK 8, so if you're working with an older version ...

JRE vs. JDK

  The JRE and the JDK are two terms you hear people mention very frequently in the Java world, and what they are the two parts that we need in order to run and create Java applications. The JRE is the Java Runtime Environment. JDK is the Java Development Kit. And so, the JRE is what you require in order to run Java applications, and end users normally install the JRE. They're the ones who are going to run our apps. The JDK provides the tools that we need to create Java apps. So, normally, developers are the ones who install the JDK on their machines. And in order to develop apps, you need to run them, so the JDK installation includes a JRE. So how does all this work together? If we sit down, and we type up a Java source file with our program code inside of it, and we want to go ahead and run that in some host environment, how do we do it? A host environment might be Windows, Linux. It could be Mac. It could even be a browser. It might be a phone running Android. How do we get from ...

What is Java?

The first thing we need to understand to get started is exactly what is Java? When someone says Java, what are they talking about? Well, Java is a programming language, but Java is also a runtime environment. It's both of those things. So, when we think about the programming language, it has things like the syntax, the data types, control flow, like looping and conditional statements and being object ‑ oriented, right, doing inheritance, and so forth. And then runtime, of course, must support those things, but it also provides things like configuration, security, a threading model, input/output, that sort of thing. So, when someone says Java, they could be referring to a programming language or the runtime environment or the whole thing. Now in general, the runtime environment someone is talking about when they just say Java is often referred to as Java Standard Edition. Right, that's kind of the basic Java environment. But it also provides other environments that derive from...

Railways will tell passengers to not charge laptops and phones at night, here is why

Indian Railways issued these instructions back in 2014 but their proper implementation seems to be starting now. HIGHLIGHTS You will soon not be able to charge your phone on a train. The restriction on phone charging will be between 11 pm and 5 am. Indian Railways found overcharging of devices caused minor fires on trains. When you travel by train in India, it is rare that you would have thought about charging your phone onboard. I mean it is not something that will occur to you before you step into a train to get on with your journey. But even though it is one of the most overlooked things, it is important. Charging your phone on a train is something that everyone does. But there is going to be a change to this simple benefit that you avail inside trains. Indian Railways has decided to put restrictions on charging mobile phones, laptops during certain hours to prevent fire hazards on trains. So, if you are traveling between 11 pm and 5 am on a train, you will not be able to cha...