
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

363 Views
To find the first non-repeating number in an array −Construct count array to store count of each element in the given array with same length and with initial value 0 for all elements.Compare each element in the array with all other elements, except itself.If match occurs increment its value in the count array.Get the index of the first non-zero element in the count array and print the element in the input array at this index.Exampleimport java.util.Arrays; public class NonRpeatingArray { public static void main(String args[]) { int array[] = {114, 225, 669, 996, 336, 6547, 669, ... Read More

2K+ Views
The fillInStackTrace() is an important method of Throwable class in Java. The stack trace can be useful to determine where exactly the exception is thrown. There may be some situations where we need to rethrow an exception and find out where it is rethrown, we can use the fillInStackTrace() method in such scenarios. Syntax public Throwable fillInStackTrace() Example public class FillInStackTraceTest { public static void method1() throws Exception { throw new Exception("This is thrown from method1()"); } public static void method2() throws Throwable { try { ... Read More

3K+ Views
In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using name and position as −System.out.println(myArray[3]); //Which is 1457Creating an array in JavaIn Java, arrays are treated as referenced types you can create an array using the new keyword similar to objects and populate it using the indices as −int myArray[] = new int[7];While creating array in this way, you must specify ... Read More

3K+ Views
In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using name and position as −System.out.println(myArray[3]); //Which is 1457Creating an array in JavaIn Java, arrays are treated as referenced types you can create an array using the new keyword similar to objects and populate it using the indices as −int myArray[] = new int[7];While creating array in this way, you must ... Read More

3K+ Views
An array is a data structure/container/object that stores a fixed-size sequential collection of elements of the same type. The size/length of the array is determined at the time of creation.The position of the elements in the array is called as index or subscript. The first element of the array is stored at the index 0 and, the second element is at the index 1 and so on.Each element in an array is accessed using an expression which contains the name of the array followed by the index of the required element in square brackets.For example, if an array of 6 elements ... Read More

5K+ Views
You can reverse a String in several ways, without using the reverse() function.Using recursion − 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. You can reverse a string using recursive function as shown in the following program.Exampleimport java.util.Scanner; public class StringReverse { public static String reverseString(String str){ if(str.isEmpty()){ return str; }else{ return reverseString(str.substring(1))+str.charAt(0); } ... Read More

19K+ Views
In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using name and position as −System.out.println(myArray[3]); //Which is 1457Creating an array in JavaIn Java, arrays are treated as referenced types you can create an array using the new keyword similar to objects and populate it using the indices as −int myArray[] = new int[7]; myArray[0] = 1254; myArray[1] = 1458; myArray[2] = ... Read More

809 Views
In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0. You can access the elements of an array using name and position as −System.out.println(myArray[3]); //Which is 1457 Creating an array in Java:In Java, arrays are treated as referenced types you can create an array using the new keyword similar to objects and populate it using the indices as −int myArray[] = new int[7]; myArray[0] = 1254; myArray[1] = ... Read More

3K+ Views
The class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories.The delete() method of the File class deletes the file/directory represented by the current File object.This ListFiles() method of the File class returns an array holding the objects (abstract paths) of all the files (and directories) in the path represented by the current (File) object.Therefore, to delete a folder along with its sub directories and files, you need to define a recursive method.ExampleFollowing Java program deletes the specified directory recursively −import java.io.File; ... Read More

3K+ Views
He class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories.The lastModified() method of the File class returns the last modified time of the file/directory represented by the current File object. You can get the last modified time of a particular file using this method.ExampleFollowing Java program gets the last modified time of a directory −import java.io.File; import java.util.Date; public class GettingLastmodifiedTime { public static void main(String args[]) { String filePath = "D://ExampleDirectory//"; //Creating the File ... Read More