0% found this document useful (0 votes)
25 views2 pages

Java Functions Cheat Sheet

This document is a cheat sheet for Java functions commonly used in coding rounds, categorized into String, Array, Math, Character, and Collections functions. Each category includes function names, examples, and their outputs for quick reference. It serves as a concise guide for developers preparing for coding interviews.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Java Functions Cheat Sheet

This document is a cheat sheet for Java functions commonly used in coding rounds, categorized into String, Array, Math, Character, and Collections functions. Each category includes function names, examples, and their outputs for quick reference. It serves as a concise guide for developers preparing for coding interviews.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Functions Cheat Sheet for Coding Rounds

1. String Functions
Function Example Output
[Link]() "hello".length() 5
[Link](i) "hello".charAt(1) 'e'
[Link]() "abc".toCharArray() ['a','b','c']
[Link]("abc") "abc".equals("abc") true
[Link](1,4) "hello".substring(1,4) "ell"
[Link]('a') "banana".indexOf('a') 1
[Link]("a","x") "apple".replace("a","x") "xpple"
new StringBuilder(str).reverse().toString() Reverse string "olleh"

2. Array Functions
Function Example Output
[Link](arr) Sort array Ascending
[Link](arr) Print array [1,2,3]
[Link](a,b) Compare arrays true/false
[Link](arr,n) Copy first n elements [1,2]
[Link](arr,1,3) Copy subarray [2,3]
[Link](arr,val) Fill array [0,0,0]

3. Math Functions
Function Example Output
[Link](a,b) [Link](5,3) 5
[Link](a,b) [Link](5,3) 3
[Link](-7) [Link](-7) 7
[Link](a,b) [Link](2,3) 8.0
[Link](x) [Link](25) 5.0
[Link](3.6) [Link](3.6) 4

4. Character Functions
Function Example Output
[Link](c) isDigit('5') true
[Link](c) isLetter('a') true
[Link](c) isLowerCase('a') true
[Link](c) isUpperCase('A') true
[Link](c) toLowerCase('A') 'a'
[Link](c) toUpperCase('a') 'A'

5. Collections
Function Example Output
[Link](x) Add element [x]
[Link](i) Get element x
[Link]() List size n
[Link](x) Check element true/false
[Link](list) Sort list Ascending
[Link](list) Reverse list Descending

You might also like