Alankritha Ammu has Published 60 Answers

Java Program to count the number of words in a String

Alankritha Ammu

Alankritha Ammu

Updated on 26-Feb-2020 08:10:14

Create a FileInputStream object by passing the required file (object) as a parameter to its constructor. Read the contents of the file using the read() method into a byte array. Instantiate a String class by passing the byte array to its constructor. Using split() method read the words of the String to an ... Read More

Write a java program to tOGGLE each word in string?

Alankritha Ammu

Alankritha Ammu

Updated on 26-Feb-2020 07:07:50

You can change the cases of the letters of a word using toUpperCase() and toLowerCase() methods.Split each word in the string using the split() method, change the first letter of each word to lower case and remaining letters to upper case.ExampleLive Demopublic class Sample{    public static void main(String args[]){   ... Read More

Difference between == and equals() method in Java.

Alankritha Ammu

Alankritha Ammu

Updated on 26-Feb-2020 06:42:24

The equals() method compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.Example Live Demopublic class Sample {    public static void main(String []args) {   ... Read More

String Concatenation by concat() method.

Alankritha Ammu

Alankritha Ammu

Updated on 26-Feb-2020 05:57:18

You can concatenate two strings using the concat() method of the String class. This class concatenates the specified string to the end of this string.ExampleLive Demopublic class Test {    public static void main(String args[]){       String str1 = "Krishna";       String str2 = "Kasyap";       System.out.println(str1.concat(str2));    } }OutputkrishnaKasyap

Java string concat() sample code examples.

Alankritha Ammu

Alankritha Ammu

Updated on 26-Feb-2020 05:18:41

You can concatenate two strings in Java either by using the concat() method or by using the ‘+’ , the “concatenation” operator.The concat() methodThe concat() method appends one String to the end of another. This method returns a String with the value of the String passed into the method, appended ... Read More

Concatenation of Strings in Java

Alankritha Ammu

Alankritha Ammu

Updated on 26-Feb-2020 05:14:28

You can finish your task by combining/ concatenating your two stings using concat() method or + operator.Exampleimport java.util.Scanner; public class ConncatSample {    public static void main(String []args) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter your first name");       String firstName = ... Read More

How to remove the last character from a string in Java?

Alankritha Ammu

Alankritha Ammu

Updated on 26-Feb-2020 05:07:49

The StringBuffer class contains a method known as deleteCharAt(). This method deletes the character at a specified index/position. You can use this method to delete/remove a particular character from a string in Java.Examplepublic class Test {    public static void main(String args[]){       String str = "hi welcome to ... Read More

Why is NullPointerException in Java?

Alankritha Ammu

Alankritha Ammu

Updated on 25-Feb-2020 05:02:26

NullPointerException is a runtime exception and it is thrown when the application try to use an object reference which has a null value.For example, using a method on a null reference.Object ref = null; ref.toString(); // this will throw a NullPointerException

Java Memory Model

Alankritha Ammu

Alankritha Ammu

Updated on 24-Feb-2020 09:21:54

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 ... Read More

Converting date type SYDATUM in a format like MM/DD/YY in SAP ABAP

Alankritha Ammu

Alankritha Ammu

Updated on 13-Feb-2020 10:53:43

It depends if you want to write it to a list screen or you want to convert it to a text variable. To write it to a list screen, you can use below code −WRITE I_my_dateMM/DD/YYYYTo convert it to a text variable, you can use below command −WRITE l_my_dateTO l_my_text ... Read More

Advertisements