Java语言程序设计课件第 4 章 数组与字符串.pptxVIP

  • 2
  • 0
  • 约3.2千字
  • 约 56页
  • 2023-11-24 发布于广东
  • 举报

Java语言程序设计课件第 4 章 数组与字符串.pptx

本章主要内容:;4.1数组;4.1.1 一维数组 ;4.1.1 一维数组;4.1.1 一维数组;4.1.1 一维数组;4.1.1 一维数组;4.1.1 一维数组;【例4-1】随机产生10个100以内的整数,并找出其中的最大数。 ;class Example4_1 { public static void main(String[] args) { int i, max; int a[] = new int[10]; int N = 100; for(i = 0; i a.length; i++) { a[i]= (int)(Math.random() * N); System.out.println( a[ + i + ] = + a[i] ); } max = a[0]; for(i = 1; i a.length; i++) if(a[i] max) max = a[i]; System.out.println( ); System.out.println(最大值max= + max ); } };;增强的for循环又称为foreach循环,是操作数组的一种简便语法,采用这种语法可以不使用下标变量即完成对数组的遍历。;1 public class Example 2 { 3 public static

文档评论(0)

1亿VIP精品文档

相关文档