Arrays: Practice Problems IV Hey! So, we have finally reached to the last article of arrays practice. Excited about the same? Let's conquer it together! Problem 1: Write a java program to merge two sorted array to third array. Input Array 1: 1, 4, 6, 9, 15 Array 2: 2, 5, 8,
Arrays: Practice Problems III Time for taking it to the next level! Problem1: Write a java program to insert an element in an array. Note: Position provided in the input is 1-indexed. Input Number of elements: 5 Elements: 10 20 30 40 50 Element to be added: 25 Position where to insert: 3 Output
Arrays: Practice Problems II What's up, buddies? Feeling confident with the knowledge of arrays you have gained! So, it's time for some warm-up. Program1: Write a java program to print all negative elements in an array. Input 10 -1 -10 100 5 61 -2 -23 8 -90 51 Output -1
Java Methods Methods Practice 1. Write a Java to check if a person is eligible to vote based on their age. Create a method to check the eligibility. Sample Input Enter your age: 19 Output You are eligibile to vote!. Try it out yourself here! Solution Code Try on Compiler! import java.util.Scanner;
Java Methods Local Variables in a Method What are Local Variables? Imagine you have a special calculator (your program) that can add two numbers. You tell it to add 2 and 5, and it does the math inside a secret box (the method). Now, imagine you want to see the result outside of the secret box. If
Java Methods Standard Library Methods Introduction So, imagine you're cooking, and you have your own recipe (those are like the methods you create). But sometimes, you use pre-made ingredients or tools (those are like the standard library methods). In Java, there are these pre-made methods that are already there for you to use
Java Methods Use of Arguments and Return Type in a Method Using arguments and return values in a method allows us to create a piece of code that can be used independently, like a helpful tool. Let's understand this with an example of a method we write to add two numbers: int addNumbers(int n1, int n2) { int result
Java Methods Method Arguments in Java Method arguments are essential in programming because they provide a way to pass data to a method, allowing it to perform tasks with varying inputs. Let's try to understand with the help of an example where we write a method to multiply two numbers. class Main { // Method to
Java Methods Methods in Java In this chapter, we're going to explore a powerful way to tidy up our code – using something called methods. As our programs get more complex, the code can start to look messy and become a bit of a puzzle. That's where methods come to the rescue!
Java Arrays Arrays: Practice Problems I 1. Write a java program to find second largest element in an array. If not exist, then return -1. Input Enter the size of the array: 10 Enter array elements: 7 2 3 8 6 6 75 38 3 2 Output 38 Try it out yourself here! Solution Code Try
Java Arrays Iterating Through Arrays Looping through an array means going through each item in the array. There are two common ways to do this in Java. Using a For Loop: String[] friends = {"Rahul", "Simran", "Kiran", "Naina", "Aman"}; for (int i = 0; i < friends.
Java Arrays Types of Array in Java There are two types of arrays. * Single Dimensional Array * Multidimensional Array Single Dimensional Array Contains only one level or dimension. It's like a simple list having a row of boxes where you can store and retrieve elements using their position (index) in the row. Syntax int[] numbers = new
Java Arrays Arrays in Java Think about needing to keep track of the ages of 100 people. It would be quite a hassle if we had to create separate variables for each person's age, right? That's where arrays come in handy. Introduction Imagine an array like a storage box that can
Java Control Flow Switch Statement in Java In our previous lessons, we learned about the if...else statement, which helps us make decisions between two options. But what if we have to choose from more than two options? For instance, let's say we're given a number from 1 to 7, and we need
Java Control Flow Break and Continue in Java The "break" statement is like a stop sign for a loop in programming. Imagine you're counting numbers using a loop, and you want to stop the counting when a certain condition is met. That's when you use "break." And the "continue&
Java Control Flow Standard Practice problems 1. Write a java program to check whether a character is alphabet, digit or special character. Example Input Input any character: E Expected output Alpabet Try it out yourself here! Hint Every character, like letters, numbers, or special symbols, has a unique number assigned to it, called the ASCII value.
Java More Articles Coming soon.. Hold tight! our team is working on more articles. We're constantly trying to bring a few new articles every week.
Java Introduction First Program in Java A "Hello, World!" program is a basic code that displays the message "Hello, World!" on the screen. It's commonly used to introduce beginners to a new programming language. // This is a comment. It's like a note for humans to read, but the
Java Introduction JVM, JRE, JDK JVM (Java Virtual Machine) Imagine the Java Virtual Machine (JVM) like a magic engine for running computer programs. Even though you can't touch or see it, it's there to make sure your Java programs work. That's why it is called a virtual machine because
Java Introduction Java vs C++ C++ Java Platform dependent, it depends on the platform, Code needs to be compiled separately for each platform, and binaries are often platform-dependent. Platform Independent, Code is compiled into an intermediate form (bytecode) that runs on the Java Virtual Machine (JVM). This enables "write once, run anywhere" (WORA)
Java Introduction Features of Java Java is a versatile and widely used programming language known for its unique features that contribute to its popularity. These features, often referred to as Java's "buzzwords," are designed to make it portable, simple, secure, and suitable for a variety of applications. Below is a compilation
Java Introduction What is Java? Imagine you have a recipe book (Java) that tells you how to make different types of delicious food items (applications). You follow the step-by-step instructions (write code) provided in the book and use various ingredients (Java features) to bake your cake (create your application). Audience Our Java programming tutorial is
Java Control Flow do....while Loop in Java The Java do-while loop is similar to what 'while' and 'for' loop that lets you do something in your program over and over again until a certain condition is met. It's useful when you're not sure how many times you want to
Java Control Flow For Loop in Java for loop is also used to iterate a specific part of the code multiple times. When you know the exact number of iterations in advance, it is recommended to use for loop. It's syntax is as follows - for (initialization; condition; increment/decrement) { // code to be executed. } Let&
Java Control Flow While Loop in Java Introduction to Loops Imagine you're in a candy shop and you want to keep buying candies until you've spent all your money. You check your wallet after each purchase, and as long as you have enough money left, you keep buying more candies. Once you run