Posts

Write program to palindrome string

//Method 1  public void PalindromeString{ //main method public static void main(String args[]) { //String declare and initiation   String s="MADAM"; String rev=""; for(int i=s,lenght()-1;i>=0;i--){   rev=rev+s.charAt(i); }       if(s.equals(rev)){        System.out.println("this is palindrome string");//MADAM        }       else{         System.out.println("This is not palindrome screen"); //!=MADAM        }   } } ===================================================== 🔹 Step 1: Start with the Concept A palindrome string is a string that reads the same forward and backward (e.g., "MADAM", "LEVEL"). The logic is to reverse the string and compare it with the original. 🔹 Step 2: Walk Through the Code String Declaration : java String s = "MADAM"; → This is the input string we want to check. Reverse Logic : java String rev = ""; for(int i = s.length() - ...

Write a program to print Reverse words from string

  Public static void main ( String args [] ) { String s="Selenium with java"; Char words[]=s.split(" "); StringBuffer reverse=new Stringbuffer (); For(String word:words) { StringBuffer sb=new StringBuffer(word); Sb.append(sb.reverse().append(" ")); } System.out.println(sb.toString()); }

Write a program to print Reverse String

# Write a program to print  reverse String   Public station void main(String args[]) { String s="patil"; String rev=""; For(int i=s length-1;i>=0;i++) { rev=rev+s.charAt(i); } System.out.println(rev); } Output: litap

Write a program to print all link present on google page || selenium code

# Write a program to get all links present on google page public static void main(String args[])  {         // Set the system property for the ChromeDriver       System.setProperty("webdriver.chrome.driver","c://desktop//cromedriver.exe");        // create new instance of ChromeDriver      WebDriver driver=new ChromeDriver();      //launch browser --> open google home page    driver.get("https://www.google.com");        // find all links on home page     List<WebElement> links=driver.findElements(By.tagName("//a"));           // Iterate through each link and print the href attribute         for(WebElement link:links)         {           String href=link.getAttribute("href").getText();           System.out.println(href);   ...