Exception Handling with Try Catch in Java
Even the best programmers make mistakes in their code. An error could occur because of a typo, an unexpected user input, or for many other reasons which are difficult to track. That’s where exception handling comes in. Good code includes…
How to Use Java Constructors
In Java, methods are used to store blocks of code that perform a specific action. When you’re working with methods, you may encounter a concept called constructors. Constructors are special methods used to initialize objects in Java. Constructors are called…
Java String Equals
Strings are a data type used to store text-based data in Java. When you’re working with strings, you may encounter a scenario where you want to compare two strings with each other. That’s where the Java string equals() and equalsIgnoreCase()…
How to Use Recursion in Java
In programming, recursion refers to the process in which a function calls itself directly or indirectly. Recursion is used to solve a number of problems in computer science. The Java programming language supports creating recursive methods, which are methods that…
How to Use the Java File Class
There are a number of scenarios where you’ll want to work with files in Java. For instance, you may want to create a file to store the output of a program, or perhaps you decide that you want to read…
Switch Statement Java: How to Use It
Conditional statements are a common feature in all programming languages. We use conditional statements to control the flow of programs. In Java, if...else statements are used to control program flow based on a certain set of conditions. Additionally, Java offers…
How to Throw an Exception in Java
Exceptions are unexpected events that occur during program execution. When your code encounters an exception, the flow of your program will be terminated. It’s important that you handle exceptions correctly when you’re coding in Java. Otherwise, your code may terminate…
How to Use Java Methods
In object-oriented programming, methods are blocks of code that perform a specific task. For instance, a method could check whether a customer has enough money in their bank account to make a purchase or sort the contents of a list…
How to Use If…Else Statements in Java
When you’re programming, it’s common to write code that should only be executed when a certain condition is met. For instance, you may want an order to be placed on your e-commerce site only if a user has submitted their…
How to Use for and for each Loops in Java
Loops in programming are used to automate similar tasks that will be repeated multiple times. For instance, if you’re creating a program that merges together the price and name of all lunchtime menu items for a restaurant, you may want…
Java toUpperCase and toLowerCase
Strings are a built-in data type in Java used to store text. When you’re working with a string, you may want to convert the case of the string to all-uppercase or to all-lowercase. For instance, if you’re building an app…
How to Use HashSet in Java
In Java, there are a number of data types that are used to store values. Each data type stores values in a different way, and offers a range of methods which can be used to manipulate the stored values. For…
How to Use the Java HashMap Class
In programming, data types are used to classify particular types of data. Each data type is stored in a different way, and the data type in which a value is stored will determine the operations which can be performed on…
How to Convert a String to an Integer in Java
Programmers use different data types to store different kinds of values. For instance, they use strings to store text-based data and integers to store whole numbers. When you are writing code, you may decide that you want to convert a…
4 Ways to Copy an Array in Java
When you’re working with arrays in Java, you may decide that you want to create a copy of an array. For instance, if you’re running a coffee shop and want to create a seasonal menu, you may want to create…
How to Write Comments in Java
When you’re coding, the first thing on your mind will be how the computer processes the code you write. However, it’s also essential to think about how people will read your code. Whether you’re working on a project with a…
JavaScript toUpperCase and toLowerCase
The JavaScript toLowerCase() method returns a string without any uppercase letters. Similarly, the toUpperCase() method returns a string without any lowercase characters. Both accept a string and return that string in a different case. When you’re working with a string…
PriorityQueue Java
How to Use PriorityQueue in Java Priority queues are used in programming to create data structures where the item of data with the highest value should be processed first by the structure. When you’re coding in Java, you may encounter…
How to Use Vector in Java
In Java, there are a wide range of classes used to store particular types of data. Each class has its own features and the class used to store a type of data determines how it can be accessed and manipulated.…
JavaScript typeof
Data types are used to store a particular type of data in a programming language. For example, strings can be used to store text-based data in code, whereas numbers can be used to store integers and floating-point numbers. When you’re…
JavaScript Variables
Variables are an integral part of almost every programming language, and are usually one of the first topics you’ll learn when you start coding. Variables can be used to store data in a program, such as strings, numbers, JSON objects,…
JavaScript for Beginners: A Handbook
JavaScript is a programming language that’s used to create dynamic content on websites. Take a moment to think about the web features you use every day. Think about how new content loads when you keep scrolling on Twitter, or how…
JavaScript toString
When you’re working with data in JavaScript, you may want to convert a data type to a string. For example, you may have an array of student names that you want to appear as a string, or a number that…
Ruby String Methods
Manipulating text is a common operation in many programming languages, and Ruby is no exception. For example, you may want to capitalize someone’s name before it is printed on an invoice, or you may want to replace someone’s apartment number…
Ruby If Statement
When you’re programming in Ruby, you may want to run certain code only if a condition is met. For example, you may want to stop a customer from buying a product if there is no stock left in inventory, or…
Ruby Array Methods
Arrays are a data type that allows you to store lists of data in your code. Data in an array can be sorted, reversed, extracted, and amended. You can also search through an array to find a specific value, and…
Ruby While Loop
Loops are used in a number of programming languages to perform a similar task multiple times. For example, if we wanted to print out the name of every employee in a list, we may want to use a loop. Or…
SQL Union
When you’re querying a database, you may want to combine the result of two or more SELECT statements. For example, you may want to get a list of the cities in which your customers are based, and the cities in…
SQL Outer Join
When you’re working with a database, you may want to query two or more tables at the same time and create a combined set of results. For example, you may want to find out the names of every employee and…
SQL Case
When you’re working with a database, you may want to run an if/then operation in your query. For example, you may want to go through a list of employees and change their probation status if they have been working with…