Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

get first character of string java

var string = "freeCodecamp";

string.charAt(0); // Returns "f"
Comment

get first letter of string in array java

		// Array of names
		String name [] = {"Clark", "Bruce", "Diana", "Barry"};
		
		// for each loop (to iterate everything inside the array)
		for (String names: name) {
			System.out.println(names.charAt(0));
		}

		/* Prints
        	C
            B
            D
            B
        */
Comment

how to return the first character in an array from a method java

public String firstElement(String[] array)
{
      if (array.length >= 1)
      {
      return array[0];
      }
      else {
          return "";
      }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java print hex format 
Java :: String by byte array in java 
Java :: full screen dialog android 
Java :: how to add elements to an empty array in java 
Java :: java generate random id 
Java :: set intersection java 
Java :: java foreach 
Java :: android string java 
Java :: why java platform independent 
Java :: use findviewbyid in fragment 
Java :: RecyclerView: No layout manager attached; skipping layout 
Java :: java string format thousand separator 
Java :: java check if enum contains value 
Java :: in place transpose in a matrix in java 
Java :: jframe border 
Java :: how to declare an array in java 
Java :: AmazonS3ClientBuilder 
Java :: replace last char in string java 
Java :: java get year 
Java :: entity cannot be resolved to a type in spring boot eclipse 
Java :: in java how to throw exception from function 
Java :: how to add 2 numbers in java 
Java :: java string remove character 
Java :: how to check if a string is numeric 
Java :: Java Queue Array Implementation 
Java :: java get bigger int 
Java :: java float 0/0 
Java :: implement the bubble sort algorithm on the following arraylist 
Java :: pivot in array 
Java :: Instant class java 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =