Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn VARARGS in 6 minutes! 💬
Play lesson

Java tutorial for beginners ☕ - Learn VARARGS in 6 minutes! 💬

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#java #javatutorial #javacourse public class Main { public static void main(String[] args){ // varargs = allow a method to accept a varying # of arguments // makes methods more flexible, no need for overloaded methods // java will pack the arguments into an array // ... (ellipsis) System.out.println(average(1, 2, 3, 4)); } static double average(double... numbers){ double sum = 0; if(numbers.length == 0){ return 0; } for(double number : numbers){ sum += number; } return sum / numbers.length; } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere