Java Guava | Bytes.asList() method with Examples Last Updated : 01 Feb, 2019 Comments Improve Suggest changes Like Article Like Report The Bytes.asList() method of Guava's Bytes Class accepts a byte array as a parameter and returns a list which has the fixed size. The returned list is backed by the byte array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected back in the list returned by the method and vice-versa. Syntax: public static List<Byte> asList(byte... backingArray) Parameter: The method accepts a mandatory parameter backingArray which is a byte array that is used to back the list. Return Value: The method Bytes.asList() returns a fixed-size list which is backed by the array passed as the argument to the method. In other words, the method returns the list view of the array. Below examples illustrate the implementation of above method: Example 1: Java // Java code to show implementation of // Guava's Bytes.asList() method import com.google.common.primitives.Bytes; import java.util.List; class GFG { // Driver's code public static void main(String[] args) { // Creating a Byte array byte arr[] = { 1, 2, 3, 4, 5 }; // Using Bytes.asList() method to wrap // the specified primitive Byte array // as a List of the Byte type List<Byte> myList = Bytes.asList(arr); // Displaying the elements in List System.out.println(myList); } } Output: [1, 2, 3, 4, 5] Example 2: Java // Java code to show implementation of // Guava's Bytes.asList() method import com.google.common.primitives.Bytes; import java.util.List; class GFG { // Driver's code public static void main(String[] args) { // Creating a Byte array byte arr[] = { 3, 5, 7 }; // Using Bytes.asList() method to wrap // the specified primitive Byte array // as a List of the Byte type List<Byte> myList = Bytes.asList(arr); // Displaying the elements in List System.out.println(myList); } } Output: [3, 5, 7] Reference: https://google.github.io/guava/releases/19.0/api/docs/com/google/common/primitives/Bytes.html#asList(byte...) Comment More infoAdvertise with us Next Article Java Guava | Bytes.asList() method with Examples S Sahil_Bansall Follow Improve Article Tags : Java java-guava Guava-Functions Guava-Bytes Practice Tags : Java Similar Reads Java Guava | Doubles.asList() method with Examples The Doubles.asList() method of Guava's Doubles Class accepts a double array as a parameter and returns a list which has the fixed size. The returned list is backed by the double array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected back i 2 min read Java Guava | Booleans.asList() method with Examples The Booleans.asList() method of Guava's Booleans Class accepts a boolean array as a parameter and returns a list which has the fixed size. The returned list is backed by the boolean array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected ba 2 min read Java Guava | Chars.asList() method with Examples The Chars.asList() method of Guava's Chars Class accepts a char array as a parameter and returns a list which has the fixed size. The returned list is backed by the char array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected back in the li 2 min read Java Guava | Longs.asList() method with Examples The Longs.asList() method of Guava's Longs Class accepts a long array as a parameter and returns a list which has the fixed size. The returned list is backed by the long array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected back in the li 2 min read Java Guava | Shorts.asList() method with Examples The Shorts.asList() method of Guava's Shorts Class accepts a short array as a parameter and returns a list which has the fixed size. The returned list is backed by the short array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected back in th 2 min read Like