Rishi Raj has Published 119 Articles

Function Expression vs Function Declaration in JavaScript?

Rishi Raj

Rishi Raj

Updated on 12-Jun-2020 11:30:56

371 Views

Function DeclarationThe “function” keyword declares a function in JavaScript. To define a function in JavaScript use the “function” keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces.Here’s an example −function sayHello(name, age) {    document.write (name ... Read More

What is the difference between transient and volatile in Java?

Rishi Raj

Rishi Raj

Updated on 26-Feb-2020 10:11:11

744 Views

transient: An instance variable is marked transient to indicate the JVM to skip the particular variable when serializing the object containing it.  This modifier is included in the statement that creates the variable, preceding the class or data type of the variable.Examplepublic transient int limit = 55;   // will ... Read More

What does the method addElement(E obj) do in java?

Rishi Raj

Rishi Raj

Updated on 26-Feb-2020 06:10:20

418 Views

The addElement(E obj) method is used to add the specified component to the end of this vector and increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity. This addElement() method is identical in functionality to the add(Object) method. The add() method returns true/false ... Read More

What does the method removeAllElements() do in java?

Rishi Raj

Rishi Raj

Updated on 25-Feb-2020 10:07:20

143 Views

The removeAllElements() method is used to remove all components from this vector and sets its size to zero. This method is identical in functionality to the clear method.Exampleimport java.util.Vector; public class VectorDemo {    public static void main(String[] args) {       Vector vec = new Vector(4);   ... Read More

What does the method peek() do in java?

Rishi Raj

Rishi Raj

Updated on 25-Feb-2020 10:01:14

315 Views

The peek() method is used to look at the object at the top of this stack without removing it from the stack.Exampleimport java.util.*; public class StackDemo {    public static void main(String args[]) {             Stack st = new Stack();       st.push("Java");   ... Read More

How to use splash vector graphics on your Responsive Site?

Rishi Raj

Rishi Raj

Updated on 25-Feb-2020 07:27:10

212 Views

Graphics for your responsive site can make it slower, but balancing it with vector graphics can help in minimizing the bandwidth. Through this, amazing graphics work great on mobile site too. Generally, canvas and SVG is used for this purpose.Use HTML5 Scalable Vector Graphics (SVG) to create a design for ... Read More

How to create a favicon for your website?

Rishi Raj

Rishi Raj

Updated on 25-Feb-2020 06:37:29

483 Views

A favicon is a little icon visible on the web browser tab, just before the page title. It is generally a logo with the smaller size.Here, you can see the favicon, The size of a favicon is 16x16 since it also gets displayed next to the URL of your site ... Read More

Instance variables in Java

Rishi Raj

Rishi Raj

Updated on 24-Feb-2020 05:08:46

23K+ 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 ... Read More

How to search for a pattern in a Java string?

Rishi Raj

Rishi Raj

Updated on 20-Feb-2020 05:16:07

3K+ Views

Java provides the java.util.regex package for pattern matching with regular expressions. You can then search for a pattern in a Java string using classes and methods of this packages.Exampleimport java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexMatches {    public static void main( String args[] ) {       String line ... Read More

How to extract the first n characters from a string using Java?

Rishi Raj

Rishi Raj

Updated on 20-Feb-2020 04:46:52

846 Views

To find the consonants in the given String compare every character in it using the charAt() method with the vowel letters and remaining are consonants.ExampleLive Demopublic class FindingConsonants {    public static void main(String args[]) {       String str = new String("Hi Welcome to Tutorialspoint");       for(int i=0; i

Previous 1 ... 3 4 5 6 7 ... 12 Next
Advertisements