Ramu Prasad has Published 69 Articles

Converting to upper case in Java.

Ramu Prasad

Ramu Prasad

Updated on 26-Feb-2020 09:41:12

269 Views

This method has two variants. The first variant converts all of the characters in this String to upper case using the rules of the given Locale. This is equivalent to calling toUpperCase(Locale.getDefault()).The second variant takes a locale as an argument to be used while converting into upper case.ExampleLive Demoimport java.io.*; ... Read More

What does the method lastIndexOf(obj o) do in java?

Ramu Prasad

Ramu Prasad

Updated on 20-Feb-2020 12:20:20

113 Views

The lastIndexOf(Object) method of the class java.util.ArrayList returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.Exampleimport java.util.ArrayList; public class ArrayListDemo {    public static void main(String[] args) {       ArrayList arrlist = new ... Read More

What does the method addAll(int, Coll C) do in java?

Ramu Prasad

Ramu Prasad

Updated on 20-Feb-2020 11:30:57

100 Views

The addAll(int index, Collection

What is the Eclipse keyboard shortcut for "public static void main(String[] args) " in Java?

Ramu Prasad

Ramu Prasad

Updated on 20-Feb-2020 05:29:13

9K+ Views

To get public static void main(String[] args) line in eclipse without typing the whole line type main and press Ctrl + space then, you will get the option for the main method select it.

How to convert JSON Array to normal Java Array?

Ramu Prasad

Ramu Prasad

Updated on 19-Feb-2020 12:24:47

3K+ Views

The get method of the JSONArray class returns the element at a particular index. Using this method, you can get the elements of the JSONArray object and populate the array with them.Exampleimport java.util.Arrays; import org.json.JSONArray; public class JsonToArray {    public static void main(String args[]) throws Exception {   ... Read More

How to declare Java array with array size dynamically?

Ramu Prasad

Ramu Prasad

Updated on 19-Feb-2020 12:09:26

2K+ Views

To declare array size dynamically read the required integer value from the user using Scanner class and create an array using the given value:Exampleimport java.util.Arrays; import java.util.Scanner; public class PopulatingAnArray {    public static void main(String args[]) {       System.out.println("Enter the required size of the array :: ... Read More

How to convert an array of objects to an array of their primitive types in java?

Ramu Prasad

Ramu Prasad

Updated on 19-Feb-2020 11:04:46

302 Views

Apache Commons provides a library named org.apache.commons.lang3 and, following is the maven dependency to add the library to your project.           org.apache.commons       commons-lang3       3.0     This package provides a class named ArrayUtils. Using the toPrimitive() method of this class ... Read More

How MySQL stored function evaluates if it got NULL value while using the dynamic values from a table?

Ramu Prasad

Ramu Prasad

Updated on 13-Feb-2020 07:13:43

239 Views

In such kind of cases when a stored function got NULL values then it will return NULL as the result. It can be understood from the example below in which we have a NULL value in the records of student ‘Mohit’. Now, when we will apply the stored function ‘avg_marks’ ... Read More

Tokenize a string in C++?

Ramu Prasad

Ramu Prasad

Updated on 11-Feb-2020 11:03:12

344 Views

First way is using a stringstream to read words seperated by spaces. This is a little limited but does the task fairly well if you provide the proper checks. example#include #include #include using namespace std; int main() {    string str("Hello from the dark side");   ... Read More

Why can C++ templates only be implemented in the header file?

Ramu Prasad

Ramu Prasad

Updated on 11-Feb-2020 10:14:53

878 Views

When you instantiate a template in C++, the compiler creates a new class. This class has all the places where you placed the template arguments replaced with the actual argument you pass to it when using it. For example −template class MyClass {    T foo;    T myMethod(T arg1, ... Read More

Advertisements