Thursday, March 11, 2021

thumbnail

Write a Java program to get the character at the given index within the String.

we can learn to get the character at the given index within the String

Approach Steps 🤔

    • Take given original string 
    • Print  original string for reference 
    • use the charAt() method to find out a character at a given index i.e original.charAt(1);
    • hold it by int type 
    •  while display time typecast int to char 
    • print out the result on the console.

Code bit :


interview Code

Practice Code in LeetCode PlayGround 🥇🥇🥇🥇

Source code :

public class MainClass {
    public static void main(String[] args) throws IOException {
        // take a Given string 
        String original = "Java Code Practice";
        // Print  original string for reference 
       System.out.println( "Given original string :--"+ original+"\n");
        // chatAt method : it is used for find out character at given index
        // hold it by int type 
        int givenIndex = original.charAt(1);
        // while display time type cast to char 
        // Print the character at given index
        System.out.println( "the character at zero index :-- "+(char)givenIndex);
    }
}



Result : 

Result string code


Learnt from this Code Bit :

  • charAt() method: this method is used for getting a character at a given index from the original string. for the above example gave an index at 1 in charAt(1)  method so got the result "a".
  • One more thing "\n" used for the next line 
  • type casting is done int to char so got it from the above code bit. 


Thank you!

:)Sagar R G
 


thumbnail

List Of Most Important Java Program Topics

will discuss in this post, the java program some important topics.

Java_Logo

the list is very useful while interview time because the questions will ask frequently. 

In my interview time, the companies are asked most of the question are below list.  I think it will help beginners who are trying to get jobs as fresher. Ok,  my interview time 80 percentage questions were asked by String coding questions, Oops concepts explanation, exception handling, Java JDBC, collection and DSA (Data structure and Algorithms). 

In this article, we can see 

 List Of Most Important Java Program Topics/Concepts For Beginners

    •  Data Type 
    •  Operators
    • Control statement
    • Selection statements
    •  Oops concepts
    • Java String 
    • method overload
    • method overriding 
    • Interface
    • Abstract
    • Access modifier
    • Java I/O concept
    • collection
    • Exception handling 
    • Java JDBC
    • Java Date
    • Polymorphism
    • Java Array
    • Java Reflection 
    • Java Regex
This is the list of very important concepts in the core java. apart from other topics are there for learning in-depth java. but I focused on the beginners level learner and job seekers as freshers.

Thank You 

FullStackDeveloper. Powered by Blogger.