Found 33676 Articles for Programming

Why use Java annotations?

varma
Updated on 24-Feb-2020 10:15:44

336 Views

Annotations provide information about java elements. Annotations can be interpreted by compiler or IDE at compile time or by JVM at runtime. Annotations can be usedto show attributes of an element: e.g. @Deprecated, @Override, or @NotNullto describe the purpose of an element of the framework, e.g. @Entity, @TestCase, @WebServiceto describe the behavior of an element: @Statefull, @TransactionBefore Java 5, XML was primarily used to store information about java objects, with annotations, this information can be stored within the java code itself.

How to call C++ functions from Java?

varun
Updated on 10-Feb-2020 10:51:32

2K+ Views

Following are the steps to use native methods.Create a header file (.h file) for a CPP program.Create CPP fileCreate a DLLIn java code, declare the method as native, load the DLL using System.loadLibrary() method and call the method.

What are native methods in Java and where should we use them?

Prabhas
Updated on 30-Jul-2019 22:30:21

491 Views

Native methods are written in a different language than java and are declared as native in Java.

What is the native keyword in Java for?

seetha
Updated on 30-Jul-2019 22:30:21

660 Views

The native keyword is used to declare a method as native. It means that method implementation is present in the different language.

How to convert a String to an int in Java

vanithasree
Updated on 25-Feb-2020 05:20:34

443 Views

Following example is converting a String to int.ExampleLive Demopublic class Tester {    public static void main(String[] args) {       String intString = "1234";       int value = new Integer(intString).intValue();       System.out.println(value);    } }Output1234

How to avoid Java code in jsp page?

radhakrishna
Updated on 30-Jul-2019 22:30:21

279 Views

You can use JSTL, JSP Standard Tag Library or EL, Expression Language to avoid scriptlets.

Pass by reference vs Pass by Value in java

Giri Raju
Updated on 25-Feb-2020 05:22:52

6K+ Views

Call by Value means calling a method with a parameter as value. Through this, the argument value is passed to the parameter.While Call by Reference means calling a method with a parameter as a reference. Through this, the argument reference is passed to the parameter.In call by value, the modification done to the parameter passed does not reflect in the caller's scope while in the call by reference, the modification done to the parameter passed are persistent and changes are reflected in the caller's scope.But Java uses only call by value. It creates a copy of references and pass them ... Read More

Difference between HashMap and HashTable in Java.

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

21K+ Views

HashMap is non-syncronized and is not thread safe while HashTable is thread safe and is synchronized. HashMap allows one null key and values can be null whereas HashTable doesn't allow null key or value. HashMap is faster than HashTable. HashMap iterator is fail-safe where HashTable iterator is not fail-safe. HashMap extends AbstractMap class where HashTable extends Dictionary class.

Difference between Object and Class in Java

Kiran Kumar Panigrahi
Updated on 12-Apr-2025 16:28:00

2K+ Views

Java is an object-oriented programming language, which means that everything in Java is represented as a class and object. Every entity with state and behavior is an object. And, classes are the templates to create objects. It contains data and functions so that it can later be accessed by their objects wherever and whenever they are needed. The main task of objects is to get the data present in the classes or use the functions in those classes to manipulate the data. It is compulsory for a class to have an object. Otherwise, it can't be used. But, an object ... Read More

Java program to display command-line arguments

Govinda Sai
Updated on 07-Nov-2024 17:45:37

13K+ Views

In this article, we will learn how to use command-line arguments in Java. Command-line arguments provide a way to pass information to a program when it is executed from the command line. These arguments are passed to the main method of the Java program as an array of String values, allowing the program to access and use them directly. Problem Statement Given a Java program, the task is to display all of the command-line arguments passed to the program when it is executed. Input Command-line arguments:this is a command line 200 -100Output args[0]: thisargs[1]: isargs[2]: aargs[3]: commandargs[4]: lineargs[5]: 200args[6]: ... Read More

Advertisements