Escolar Documentos
Profissional Documentos
Cultura Documentos
Method Defintion:-
returntype methodname(parameters)
{
body
[return expression];
}
Method Calling :-
methodname(arguments);
class Demo
{
void display(String text)
{
System.out.println(text);
}
------------------------------------------------------------
class String
{
....
....
....
}
String s = "hello";
String t = "welcome";
String s = "hello";
int l = s.length(); // 5
--------------------------------------------------
charAt(index) :- return character at given index.
String s = "hello";
char a = s.charAt(2); // 'l'
---------------------------------------------------
String s = "hello";
----------------------------------------------------
String s = "HeLLo";
------------------------------------------------------
String s = "Hello";
int i = s.indexOf('e'); // 1
------------------------------------------------------
int i = s.lastIndexOf('l'); // 3
--------------------------------------------------------
-----------------------------------------------------------
String s = "abcdef";
String t = "abcdef";
------------------------------------------------------------
// ["String","is","a","java","predefine","class"]
----------------------------------------------------------