Articles on Trending Technologies

Technical articles with clear explanations and examples

A closer look at Java "Hello World" program

Daniol Thomas
Daniol Thomas
Updated on 11-Mar-2026 407 Views

Let us look at a simple code that will print the words Hello World.Examplepublic class MyFirstJavaProgram {    /* This is my first java program. *    This will print 'Hello World' as the output */    public static void main(String []args) {       System.out.println("Hello World"); // prints Hello World    } }Let's look at how to save the file, compile, and run the program. Please follow the subsequent steps −Open notepad and add the code as above.Save the file as: MyFirstJavaProgram.java.Open a command prompt window and go to the directory where you saved the class. Assume it's ...

Read More

Java program to print the transpose of a matrix

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 2K+ Views

The transpose of a matrix is the one whose rows are columns of the original matrix, i.e. if A and B are two matrices such that the rows of the matrix B are the columns of the matrix A then Matrix B is said to be the transpose of Matrix A.To print the transpose of the given matrix −Create an empty matrix.Copy the contents of the original matrix to the new matrix such that elements in the [j][i] position of the original matrix should be copied to the [i][j] position of the new matrix.Print the new matrix.Examplepublic class TransposeSample{   ...

Read More

Why can't we define a static method in a Java interface?

Anjana
Anjana
Updated on 11-Mar-2026 853 Views

From Java 8 onwards, static methods are allowed in Java interfaces.An interface can also have static helper methods from Java 8 onwards. public interface vehicle {    default void print() {       System.out.println("I am a vehicle!");    }    static void blowHorn() {       System.out.println("Blowing horn!!!");    } }Default Method ExampleCreate the following Java program using any editor of your choice in, say, C:\> JAVA.Java8Tester.javapublic class Java8Tester {    public static void main(String args[]) {       Vehicle vehicle = new Car(); vehicle.print();    } } interface Vehicle {    default void print() {   ...

Read More

How do I time a method execution in Java

Manikanth Mani
Manikanth Mani
Updated on 11-Mar-2026 1K+ Views

You should get a start time before making a call and end time after method execution. The difference is the time taken. Exampleimport java.util.Calendar; public class Tester {    public static void main(String[] args) {       long startTime = Calendar.getInstance().getTimeInMillis();       longRunningMethod();       long endTime = Calendar.getInstance().getTimeInMillis();       System.out.println("Time taken: " + (endTime - startTime) + " ms");    }    public static void longRunningMethod() {       try {          Thread.sleep(1000);       } catch (InterruptedException e) {          e.printStackTrace();       }    } }OutputTime taken: 1012 ms

Read More

Function pointers in Java

Akshaya Akki
Akshaya Akki
Updated on 11-Mar-2026 2K+ Views

From Java 8 onwards, the lambda expression is introduced which acts as function pointers.Lambda expressions are introduced in Java 8 and are touted to be the biggest feature of Java 8. Lambda expression facilitates functional programming and simplifies the development a lot.SyntaxA lambda expression is characterized by the following syntax.parameter -> expression bodyFollowing are the important characteristics of a lambda expression.Optional type declaration − No need to declare the type of a parameter. The compiler can inference the same from the value of the parameter.Optional parenthesis around parameter − No need to declare a single parameter in parenthesis. For multiple ...

Read More

Local variables in Java

Syed Javed
Syed Javed
Updated on 11-Mar-2026 2K+ Views

Local variables are declared in methods, constructors, or blocks.Local variables are created when the method, constructor or block is entered and the variable will be destroyed once it exits the method, constructor, or block.Access modifiers cannot be used for local variables.Local variables are visible only within the declared method, constructor, or block.Local variables are implemented at stack level internally.There is no default value for local variables, so local variables should be declared and an initial value should be assigned before the first use.ExampleHere, age is a local variable. This is defined inside pupAge()method and its scope is limited to only ...

Read More

Member variables in Java

Kumar Varma
Kumar Varma
Updated on 11-Mar-2026 11K+ Views

Member variables are known as instance variables in java.Instance variables are declared in a class, but outside a method, constructor or any block.When space is allocated for an object in the heap, a slot for each instance variable value is created.Instance variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed.Instance variables hold values that must be referenced by more than one method, constructor or block, or essential parts of an object's state that must be present throughout the class.Instance variables can be declared in a class level ...

Read More

Bootstrap panel-heading class

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 476 Views

Use the .panel-heading class to add a panel to headings in Bootstrap.You can try to run the following code to implement a panel-heading classExample           Bootstrap Example                                                       Panel Heading                                 Demo content                                                            Panel Heading                                             Demo content                    

Read More

Bootstrap progress-striped class

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 11-Mar-2026 369 Views

The progress-striped class is used to form a striped progress bar in Bootstrap.You can try to run the following code to create a striped progress bar in BootstrapExample           Bootstrap Example                                 Striped Progress Bars       Success Progress Bar                             45%Complete (success)                       Info Progress Bar                             80% Complete (info)                    

Read More

Bootstrap 4 .card-img-bottom class

Kristi Castro
Kristi Castro
Updated on 11-Mar-2026 579 Views

Use the card-img-bottom class in Bootstrap 4 to place an image at the bottom inside a Bootstrap 4 card.Set the card body, and within that, the card title and card text −   Quantitative Aptitude   For Entrance Exams   Sample Questions Now set image with class “card-img-bottom”−Let us see an example to learn how to implement Bootstrap 4 .card-img-bottom class −Example       Bootstrap Example                             Quantitative Aptitude Questions Answers                   Quantitative Aptitude         For Entrance Exams         Sample Questions                    

Read More
Showing 24771–24780 of 61,297 articles
Advertisements