Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Ramu Prasad
48 articles
How to create a zero-filled JavaScript array?
To create a zero-filled JavaScript array, use the Unit8Array typed array.ExampleYou can try to run the following code: var arr1 = ["marketing", "technical", "finance", "sales"]; var arr2 = new Uint8Array(4); document.write(arr1); document.write("Zero filled array: "+arr2);
Read MoreSingle level inheritance in Java
Single Level inheritance - A class inherits properties from a single class. For example, Class B inherits Class A.Exampleclass Shape { public void display() { System.out.println("Inside display"); } } class Rectangle extends Shape { public void area() { System.out.println("Inside area"); } } public class Tester { public static void main(String[] arguments) { Rectangle rect = new Rectangle(); rect.display(); rect.area(); } }OutputInside display Inside areaHere Rectangle class inherits Shape class and can execute two methods, display() and area() as shown.
Read MoreHow to reverse the elements of an array using stack in java?
Stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example – a deck of cards or a pile of plates, etc.A stack is first in first out, it has two main operations push and pop. Push inserts data in to it and pop retrieves data from it.To reverse an array using stack initially push all elements in to the stack using the push() method then, retrieve them back using the pop() method into another array.Exampleimport java.util.Arrays; import java.util.Stack; public class ReversinArrayUsingStack { ...
Read MoreHow to store the contents of arrays in a file using Java?
You can use write data into a file using the Writer classes. In the example given below, we are writing the contents of the array using the BufferedWriter.Exampleimport java.io.BufferedWriter; import java.io.FileWriter; public class WritingStringArrayToFile { public static void main(String args[]) throws Exception { String[] myArray = {"JavaFX", "HBase", "OpenCV", "Java", "Hadoop", "Neo4j"}; BufferedWriter writer = new BufferedWriter(new FileWriter("myFile.txt", false)); for(int i = 0; i < myArray.length; i++) { writer.write(myArray[i].toString()); writer.newLine(); } writer.flush(); ...
Read MoreHow to redirect to another webpage using JavaScript?
The window.location object contains the current location or URL information. We can redirect the users to another webpage using the properties of this object. window.location can be written without the prefix window.We use the following properties of the window.location object to redirect the users to another webpage −window.location.href- it returns the URL (href) of the current page.window.location.replace()- it replaces the current document with new document.window.location.assign() loads a new document.The syntaxes below are used to redirect to another web page. We omit the window prefix and use only location in all the program examples. You can try running the programs using ...
Read MoreHow to fix Array indexOf() in JavaScript for Internet Explorer browsers?
To fix Array.indexOf() for Internet Explorer web browser, use the following −jQuery.inArray( value, array [, fromIndex ] )Add the following,
Read MoreWhy does the JavaScript need to start with “;”?
JavaScript uses a semi-colon (;) to avoid any confusion in code, especially the beginning of a new line.ExampleYou can still use the following to avoid any chaos in the code −return { 'var':myVal } // using semi-colon; (function( $ ) { // }
Read MoreHow to set the capitalization of a text with JavaScript?
To set the capitalization, use the textTransform property in JavaScript. Set it to capitalize, if you want the first letter of every word to be a capital letter.ExampleYou can try to run the following code to return the capitalization of a text with JavaScript − Capitalize Text This is demo text! This is demo text! function display() { document.getElementById("myID").style.textTransform = "capitalize"; }
Read MoreHow to search the querystring part of the href attribute of an area in JavaScript?
To get the querystring of the href attribute of an area, use the search property. You can try to run the following code to search the querystring −Example var x = document.getElementById("myarea").search; document.write("Querystring: "+x);
Read MoreHow to get the list of document properties which can be accessed using W3C DOM?
The following are the document properties which can be accessed using W3C DOM −Sr.NoProperty & Description1BodyA reference to the Element object that represents the tag of this document.Ex − document.body2DefaultViewIts Read-only property and represents the window in which the document is displayed.Ex − document.defaultView3DocumentElementA read-only reference to the tag of the document.Ex − document.documentElement8/31/20084ImplementationIt is a read-only property and represents the DOMImplementation object that represents the implementation that created this document.Ex − document.implementation
Read More