Java Technologies Articles

Page 3 of 4

Write an example to find whether a given string is palindrome using recursion

Arjun Thakur
Arjun Thakur
Updated on 13-Mar-2020 1K+ Views

Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.Following is an example to find palindrome of a given number using recursive function.Examplepublic class PalindromeRecursion {    public static boolean isPalindrome(String str){       if(str.length() == 0 ||str.length()==1){          return true;       }       if(str.charAt(0) == str.charAt(str.length()-1)){          return isPalindrome(str.substring(1, str.length()-1));       }       return false; ...

Read More

Incremental Java infinite loop

Abhinanda Shri
Abhinanda Shri
Updated on 12-Mar-2020 239 Views

ExampleFollowing is the required program −Live Demopublic class Tester {    public static void main(String args[]) {       int i = 0;       do {          i++;          System.out.println(i);       }while (true);    } }The output will keep printing numbers in sequential order.

Read More

Local variables in Java

Syed Javed
Syed Javed
Updated on 12-Mar-2020 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

What is the Java Runtime Environment (JRE)?

Ayyan
Ayyan
Updated on 25-Feb-2020 617 Views

JRE is Java Runtime Environment and is the machine-specific implementation of JVM. It contains libraries like rt.jar, class loaders etc which are used by JVM.

Read More

Java Memory Model

Alankritha Ammu
Alankritha Ammu
Updated on 24-Feb-2020 3K+ Views

Java memory model is divided between Thread Stacks (One for each thread) and a heap area.Thread Stack: It is a thread specific memory area and contains local variables, methods call information etc. JVM stacks could be of fixed size or variable size. If computation in a thread exceeds its stack size limit then JVM throws StackOverflowError and exits.HeapIt contains all the objects created during application lifecycle. The heap is created when the virtual machine starts up. Garbage collector reclaims heap storage for objects and objects are never explicitly deallocated. The JVM is not using any automatic storage management system, and ...

Read More

Member variables vs Local variables in Java

Vikyath Ram
Vikyath Ram
Updated on 24-Feb-2020 2K+ Views

Local VariableLocal 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.Instance/Member VariableInstance variables are declared in a class, but outside a method, constructor or any block.When a ...

Read More

Instance variables in Java

Rishi Raj
Rishi Raj
Updated on 24-Feb-2020 24K+ Views

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 at the class level before or after use.Access modifiers can be given ...

Read More

Member variables in Java

Kumar Varma
Kumar Varma
Updated on 24-Feb-2020 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

branching statement in Java

Kumar Varma
Kumar Varma
Updated on 30-Jul-2019 830 Views

Java programming language provides following types of decision making or branching statements.Java programming language provides following types of decision making statements.Sr.No.Statement & Description1if statementAn if statement consists of a boolean expression followed by one or more statements.2if...else statementAn if statement can be followed by an optional else statement, which executes when the boolean expression is false.3nested if statementYou can use one if or else if statement inside another if or else if statement(s).4switch statementA switch statement allows a variable to be tested for equality against a list of values.

Read More

How can we edit a java program?

Alankritha Ammu
Alankritha Ammu
Updated on 30-Jul-2019 805 Views

Java programs are simple text-based programs and can be edited using any text editor like notepad etc. The filename should be same as class name.

Read More
Showing 21–30 of 40 articles
Advertisements