[Link]("[Link]
dev/apps/popup/#");
webelement open=[Link]([Link]("login"));
[Link](open);
webelement submit=[Link]([Link]("//*[@id="wrapper"]/button"));
[Link](submit);
[Link]("[Link]
[Link](open);
//td[@headers='CIPLA']/following-sibling::td[1]
class Test{
static int count=0;
Test(){
count++;
[Link](count);
}
public static void main(String args[]){
Test c1=new Test();
Test c2=new Test();
Test c3=new Test();
}
}
[Link](windowhandles);
[Link](parentURL);
[Link](childURL);
file srcfile=((TakeScreenshot)driver).getScreenshotas([Link]);
Certainly! Here's a consolidated reference sheet for common Java `String` methods:
---
## Java `String` Methods Reference Sheet
### **1. `length()`**
- **Description:** Returns the length of the string.
- **Example:**
```java
String str = "Hello";
int length = [Link](); // 5
```
### **2. `charAt(int index)`**
- **Description:** Returns the character at the specified index.
- **Example:**
```java
char ch = [Link](1); // 'e'
```
### **3. `substring(int beginIndex)`**
- **Description:** Returns a substring from the specified index to the end of the
string.
- **Example:**
```java
String sub = [Link](1); // "ello"
```
### **4. `substring(int beginIndex, int endIndex)`**
- **Description:** Returns a substring from the specified begin index to end index.
- **Example:**
```java
String sub = [Link](1, 4); // "ell"
```
### **5. `indexOf(String str)`**
- **Description:** Returns the index of the first occurrence of the specified
substring.
- **Example:**
```java
int index = [Link]("l"); // 2
```
### **6. `indexOf(String str, int fromIndex)`**
- **Description:** Returns the index of the first occurrence of the specified
substring, starting the search at the specified index.
- **Example:**
```java
int index = [Link]("l", 3); // 3
```
### **7. `lastIndexOf(String str)`**
- **Description:** Returns the index of the last occurrence of the specified
substring.
- **Example:**
```java
int index = [Link]("l"); // 3
```
### **8. `lastIndexOf(String str, int fromIndex)`**
- **Description:** Returns the index of the last occurrence of the specified
substring, searching backward starting at the specified index.
- **Example:**
```java
int index = [Link]("l", 2); // 2
```
### **9. `contains(CharSequence sequence)`**
- **Description:** Checks if the string contains the specified sequence of
characters.
- **Example:**
```java
boolean contains = [Link]("ell"); // true
```
### **10. `startsWith(String prefix)`**
- **Description:** Checks if the string starts with the specified prefix.
- **Example:**
```java
boolean starts = [Link]("Hel"); // true
```
### **11. `endsWith(String suffix)`**
- **Description:** Checks if the string ends with the specified suffix.
- **Example:**
```java
boolean ends = [Link]("lo"); // true
```
### **12. `equals(Object anObject)`**
- **Description:** Compares the string to the specified object for equality.
- **Example:**
```java
boolean isEqual = [Link]("Hello"); // true
```
### **13. `equalsIgnoreCase(String anotherString)`**
- **Description:** Compares the string to the specified string, ignoring case
considerations.
- **Example:**
```java
boolean isEqualIgnoreCase = [Link]("HELLO"); // true
```
### **14. `compareTo(String anotherString)`**
- **Description:** Compares the string to the specified string lexicographically.
- **Example:**
```java
int comparison = [Link]("Hello"); // 0
```
### **15. `compareToIgnoreCase(String str)`**
- **Description:** Compares the string to the specified string lexicographically,
ignoring case.
- **Example:**
```java
int comparisonIgnoreCase = [Link]("HELLO"); // 0
```
### **16. `toUpperCase()`**
- **Description:** Converts all characters in the string to uppercase.
- **Example:**
```java
String upperCase = [Link](); // "HELLO"
```
### **17. `toLowerCase()`**
- **Description:** Converts all characters in the string to lowercase.
- **Example:**
```java
String lowerCase = [Link](); // "hello"
```
### **18. `trim()`**
- **Description:** Removes leading and trailing whitespace.
- **Example:**
```java
String trimmed = " Hello ".trim(); // "Hello"
```
### **19. `replace(char oldChar, char newChar)`**
- **Description:** Replaces all occurrences of the specified character with a new
character.
- **Example:**
```java
String replaced = [Link]('l', 'x'); // "Hexxo"
```
### **20. `replace(CharSequence target, CharSequence replacement)`**
- **Description:** Replaces all occurrences of the specified sequence with a new
sequence.
- **Example:**
```java
String replaced = [Link]("l", "x"); // "Hexxo"
```
### **21. `split(String regex)`**
- **Description:** Splits the string around matches of the given regular
expression.
- **Example:**
```java
String[] parts = "a,b,c".split(","); // ["a", "b", "c"]
```
### **22. `join(CharSequence delimiter, CharSequence... elements)`**
- **Description:** Concatenates the elements of the array into a single string,
separated by the specified delimiter.
- **Example:**
```java
String joined = [Link]("-", "2024", "08", "16"); // "2024-08-16"
```
### **23. `valueOf(int i)`**
- **Description:** Returns the string representation of the specified integer.
- **Example:**
```java
String num = [Link](123); // "123"
```
### **24. `format(String format, Object... args)`**
- **Description:** Returns a formatted string using the specified format string and
arguments.
- **Example:**
```java
String formatted = [Link]("Hello %s", "World"); // "Hello World"
```
### **25. `concat(String str)`**
- **Description:** Concatenates the specified string to the end of this string.
- **Example:**
```java
String concatenated = [Link](" World"); // "Hello World"
```
### **26. `toCharArray()`**
- **Description:** Converts the string to a new character array.
- **Example:**
```java
char[] charArray = [Link](); // ['H', 'e', 'l', 'l', 'o']
```
### **27. `isEmpty()`**
- **Description:** Checks if the string is empty (i.e., has a length of 0).
- **Example:**
```java
boolean isEmpty = "".isEmpty(); // true
```
### **28. `codePointAt(int index)`**
- **Description:** Returns the Unicode code point at the specified index.
- **Example:**
```java
int codePoint = [Link](0); // 72 ('H')
```
### **29. `codePointBefore(int index)`**
- **Description:** Returns the Unicode code point before the specified index.
- **Example:**
```java
int codePointBefore = [Link](1); // 72 ('H')
```
### **30. `codePointCount(int beginIndex, int endIndex)`**
- **Description:** Returns the number of Unicode code points in the specified text
range.
- **Example:**
```java
int codePointCount = [Link](0, 5); // 5
```
### **31. `offsetByCodePoints(int index, int codePointOffset)`**
- **Description:** Returns the index within the string that is offset by the
specified number of code points.
- **Example:**
```java
int offset = [Link](0, 2); // 2
```
---
This reference sheet covers the most commonly used methods in the `String` class in
Java. It provides a brief description and example code for each method, making it a
handy resource for string manipulation tasks.
int[] arr=[23,45,65,75,68,69]
int largest=0;
int second=0;
for(int i=0;i<[Link];i++){
if (arr[i]>largest){
largest=arr[i];
}
}
for(int i=0;i<[Link];i++){
if(arr[i]!=largest){
if(arr[i]>second);
second=arr[i];
}
[Link]("largest is" +largest);
[Link]("second largest is" +second);
}
Employee
EmpID, EName, ESalary
Department
DeptID, DName, EmpNumber
write a query to find Employee Name whose salary is greater than 5000 and less than
10000 and whose DName='IT'
P}"{
Select Sel=new Select(driver);
[Link]("Name (A to Z)");
<select class="product_sort_container" data-test="product-sort-container"><option
value="az">Name (A to Z)</option><option value="za">Name (Z to A)</option><option
value="lohi">Price (low to high)</option><option value="hilo">Price (high to
low)</option></select>
<div class="inventory_item_price" data-test="inventory-item-price">$7.99</div>
Arraylist <int> price=new Arraylist<int>();
[Link]
string s="This is Mahesh"
for (String s:words){
if([Link](""[A-Z].*));
[Link](s)}
}
public class Myclass
{
private int x = 10;
static int m1() {
int y = x;
return y;
}
public static void main(String[] args) {
[Link](m1()); }
1
1 2
1 2 3
1 2 3 4
int n
for (int x=1;x<=n;x++);{
for (int y=1;y<+x;y++);{
[Link](y+"");
}
[Link]();
public class Myclass {
static int a = 20;
Myclass() {
a++;
}
void m1() {
a++;
[Link](a);
}
public static void main(String[] args)
{
Myclass obj = new Myclass();
Myclass obj2 = new Myclass();
Myclass obj3 = new Myclass();
obj3.m1();
}
}
has context menu
ArrayList<String> cars=new ArrayList<>();
[Link]("BMW");
[Link]("Audi");
String car=[Link](1);
@DataProvider(name="logindata")
returnObject[][]{
{"user1","pwd1"},
{"user2","pwd2"},
{"user3","pwd3"}
}
@Test(dataProvider="")
git pull
git commit
git push;
POST [Link]/employee/addemp
String requestBody="{\n + "\companyname\",\n\"\empname\"}"
int num=121;
int rev=0;
while(num!=0){
rev=rev*10+num%10; //11+110
num=num/10;
}
syso(rev):
webdriver wait= new fluentwait
(timeunit,second).pollingevery(timeunit,second).ignoring([Link]);
Select sel=new select(element);
webelement element=[Link]
[Link](id);
[Link]();
select date as Current_date;
Employee
EmpID, EName, ESalary
Department
DeptID, DName, EmpNumber
write a query to find Employee Name whose salary is greater than 5000 and less than
1000 and whose DName='IT'
SELECT [Link]
from Employee E
JOIN Departement D
[Link]=[Link]
WHERE [Link]>5000 AND [Link] <1000 AND [Link]='IT'