Posts

What is char charAt (int index) in Java, and how can I use it?

Java String charAt() method The Java String charAt() method returns the character at the specified index. The index value should lie between 0 and length()-1. Signature: public char charAt(int index) Parameter: index- Index of the character to be returned. Return: returns character at the specified position. Exception: StringIndexOutOfBoundsException- If index is negative or greater then the length of the String. Example: To show working of  charAt()  method class Gfg {      public static void main(String args[])      {          String s = "Welcome! to Java Planet" ;              char ch = s.charAt( 3 );          System.out.println(ch);              ch = s.charAt( 0 );          Syst...

What are concatenating strings in Java, and how do you use it?

String Concatenation in Java In java, string concatenation forms a new string  that is  the combination of multiple strings. There are two ways to concat string in java: By + (string concatenation) operator By concat() method 1) String Concatenation by + (string concatenation) operator Java string concatenation operator (+) is used to add strings. For Example: class TestStringConcatenation1{ public static void main(String args[]){ String s="Sachin"+" Tendulkar"; System.out.println(s);//Sachin Tendulkar } } Output:Sachin Tendulkar The  Java compiler transforms  above code to this: String s=(new StringBuilder()).append("Sachin").append(" Tendulkar).toString(); In java, String concatenation is implemented through the StringBuilder (or StringBuffer) class and its append method. String concatenation operator produces a new string by appending the second operand onto the end of the first operand. The string concatenation oper...

What is the use of Thread.sleep() method in Java?

Thread.sleep() : The  java.lang.Thread.sleep(long millis)  method causes the currently executing thread to sleep for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers. Declaration Following is the declaration for  java.lang.Thread.sleep()  method public static void sleep(long millis) throws InterruptedException Parameters millis  − This is the length of time to sleep in milliseconds. Return Value This method does not return any value. Exception InterruptedException  − if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown. Example The following example shows the usage of java.lang.Thread.sleep() method. import java.lang.*; public class ThreadDemo implements Runnable { Thread t; public void run() {  for (int i = 10; i < 13; i++) {  System.out.println(Thread.currentThread().ge...

What are DBMS languages?

Image
Database Language A DBMS has appropriate languages and interfaces to express database queries and updates. Database languages can be used to read, store and update the data in the database. Types of Database Language   1. Data Definition Language DDL  stands for  D ata  D efinition  L anguage. It is used to define database structure or pattern. It is used to create schema, tables, indexes, constraints, etc. in the database. Using the DDL statements, you can create the skeleton of the database. Data definition language is used to store the information of metadata like the number of tables and schemas, their names, indexes, columns in each table, constraints, etc. Here are some tasks that come under DDL: Create:  It is used to create objects in the database. Alter:  It is used to alter the structure of the database. Drop:  It is used to delete objects ...

Daily Current Affairs 24th August 2019 | Daily GK Update

National News 1. Former finance minister Arun Jaitley passes away  Former Union finance minister and senior BJP leader  Arun Jaitley  passed away. He was a lawyer by profession. He held the portfolios of Finance Ministry, Corporate Affairs Ministry, Defence Ministry, and Minister of Information and Broadcasting. 2. President Kovind inaugurates the First World Youth Conference i.  President Ram Nath Kovind inaugurated the  first-ever World Youth Conference.  Which was organised by the  UNESCO Mahatma Gandhi Institute of Education for Peace and Sustainable Development (MGIEP) at Vigyan Bhavan, Delhi. ii.  The theme of the conference was  ‘Vasudhaiva Kutumbakam: Gandhi for the Contemporary World: Celebrating the 150th birth anniversary of Mahatma Gandhi.   iii.  The conference was in commemoration of the 150th birth anniversary celebrations of Mahatma Gandhi and aimed at providing youth with creative, effective me...