Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

NotesString

The document provides an overview of string manipulation in Java, including string creation, concatenation, trimming, and character extraction using methods like charAt and indexOf. It also covers string comparison with equals and equalsIgnoreCase, as well as a simple password validation example using DataInputStream. Additionally, it mentions date and time handling with the GregorianCalendar class.

Uploaded by

tanwararun5
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

NotesString

The document provides an overview of string manipulation in Java, including string creation, concatenation, trimming, and character extraction using methods like charAt and indexOf. It also covers string comparison with equals and equalsIgnoreCase, as well as a simple password validation example using DataInputStream. Additionally, it mentions date and time handling with the GregorianCalendar class.

Uploaded by

tanwararun5
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Strings

String is a collection of character every string terminates itself with NULL.


String s="Hello Arun";
String ss=new String("Hey Omkara");
String sss=" KKKKK Karan";
String
Concat

String ssss;
ssss=s+ss+sss;

Trim
Convert
uppercase toUpper
lowercase toLower

string_element.

To extract a character from specific position (Index)


charAt
System.out.println(s.charAt(0));
H
indexOf returns the index of a character
if does not exist then some -ve number is returned
indexOf(char,int) int start

System.out.println(s.indexOf('u'));
to compare
equals
equalsIgnoreCase

s.equals(y) true/false
true is returned only if the two strings match exactly
if you want to ignore case
s.equalsIgnoreCase(y) true/false
s.concat(ss);
s.concat(sss.trim())

Hello Arun Hey OmkaraKKKKK Karan


if(s.compare(ss))

lang
System.out.println(s.reverse()); nurA olleH

util
Date
Date
getDate();
getTime()
getHour();
getMinute();
getSecond()

GeorgeanCalender calender=new GeorgeanCalender();

calender
getDay();
getMonth();
getYear();
getHour();
getSecond();
getMinute();

import java.util.*;

Password

class string_test
{
public static void main(String ss[]) throws IOException
{
String pwd="TEST",upwd;
DataInputStream dis=new DataInputStream(System.in);
System.out.println("\n Please Enter the Password");
upwd=dis.readLine();
if(pwd.equals(upwd))
{
teststatus tt=new teststatus();
}
}
}

You might also like