当前位置: 首页 > news >正文

如何微信做演讲视频网站国内b站不收费网站有哪些

如何微信做演讲视频网站,国内b站不收费网站有哪些,河南靠谱seo电话,优化网站怎么做文章目录 前言一、什么是方法?二、方法的定义与调用1. 方法的定义2. 方法的调用3. 练习:定义比大小方法并调用 三、方法的重载四、递归五、可变参数拓展:命令行传递参数 前言 本章将学习java方法。 一、什么是方法? java方法是用…

文章目录

  • 前言
  • 一、什么是方法?
  • 二、方法的定义与调用
    • 1. 方法的定义
    • 2. 方法的调用
    • 3. 练习:定义比大小方法并调用
  • 三、方法的重载
  • 四、递归
  • 五、可变参数
  • 拓展:命令行传递参数


前言

本章将学习java方法。


一、什么是方法?

  • java方法是用来实现特定功能的一些语句块的集合
  • 一个方法只完成一个功能
  • 方法的命名规则适用于小驼峰命名法

二、方法的定义与调用

1. 方法的定义

修饰符 返回值类型 方法名(参数类型 参数名){...方法体...return 返回值;
}

在这里插入图片描述
在这里插入图片描述
实例:

    //1.定义一个add方法,实现两个数求和的功能public static int add(int num1, int num2){return num1 + num2;}

2. 方法的调用

Java 支持两种调用方法的方式,根据方法是否返回值来选择。

  1. 当方法返回一个值时,方法的调用通常被当作一个值(示例)
  2. 当方法返回值是void时,通常返回一条语句

实例:
method.java文件

public class method {public static void main(String[] args) {int a = 2;int b = 4;//2.调用add方法,并创建sum变量存储,方便后续操作int sum = add(a,b);//调用方法return的值System.out.println(sum);}
}

在这里插入图片描述
完整的代码:
method.java文件

public class method {public static void main(String[] args) {int a = 2;int b = 4;//2.调用add方法,并创建sum变量存储,方便后续操作int sum = add(a,b);//调用方法return的值System.out.println(sum);}//1.定义一个add方法,实现两个数求和的功能public static int add(int num1, int num2){return num1 + num2;}
}

在这里插入图片描述

3. 练习:定义比大小方法并调用

 public static void main(String[] args) {int num1 = 20;int num2 = 10;//调用int max = max(num1,num2);System.out.println(max);}//定义比大小方法public static int max(int num1, int num2){int result = 0;if(num1 == num2){System.out.println("两个数相等");return 0;//终止程序,不再执行之后的语句}if(num1 > num2){result = num1;}else{result = num2;}return result;}

三、方法的重载

  1. 概念:在一个类中定义了多个同名方法,但是参数列表不同
  2. 规则:方法名必须相同,参数列表必须不同

实例:
method.java文件

public class method {public static void main(String[] args) {int a = 2;int b = 4;//调用add方法,并创建sum变量存储,方便后续操作int sum = add(a,b);System.out.println(sum);System.out.println(add(1,2,3));//调用重载的add方法}//定义一个方法,实现两个数求和的功能public static int add(int num1, int num2){return num1 + num2;}//add方法的重载public static double add(double num1, double num2, double num3){return num1 + num2 + num3;}

注意:仅仅返回类型不同不足以称之方法的重载

四、递归

五、可变参数

  1. 概念:当不确定实参需要传递几个参数时,写在形式参数中的参数
  2. 注意:尽量少用,避免重载带有可变参数的方法。

方法的可变参数的声明如下所示:

typeName... parameterName

实例:
VariableParameter.java文件

public class VariableParameter {public static void main(String[] args) {test(1,2,3,4);}public static void test(int... i){System.out.println(i[0]);System.out.println(i[1]);System.out.println(i[2]);System.out.println(i[3]);}
}

拓展:命令行传递参数


文章转载自:
http://horoscopic.tsnq.cn
http://autoeroticism.tsnq.cn
http://disconcerted.tsnq.cn
http://cloxacillin.tsnq.cn
http://straggling.tsnq.cn
http://kinky.tsnq.cn
http://inducement.tsnq.cn
http://persist.tsnq.cn
http://hypoazoturia.tsnq.cn
http://lunanaut.tsnq.cn
http://tropotaxis.tsnq.cn
http://sergeant.tsnq.cn
http://editorialize.tsnq.cn
http://brassy.tsnq.cn
http://jadish.tsnq.cn
http://theistic.tsnq.cn
http://crenation.tsnq.cn
http://precocity.tsnq.cn
http://firelight.tsnq.cn
http://peacenik.tsnq.cn
http://alumna.tsnq.cn
http://briquet.tsnq.cn
http://malefic.tsnq.cn
http://panavision.tsnq.cn
http://sylvics.tsnq.cn
http://gjetost.tsnq.cn
http://monarch.tsnq.cn
http://wherefore.tsnq.cn
http://respect.tsnq.cn
http://agamogenesis.tsnq.cn
http://berceau.tsnq.cn
http://prohibiter.tsnq.cn
http://palmful.tsnq.cn
http://unright.tsnq.cn
http://ptochocracy.tsnq.cn
http://reindeer.tsnq.cn
http://gravettian.tsnq.cn
http://thereafter.tsnq.cn
http://imperatively.tsnq.cn
http://nc.tsnq.cn
http://gypster.tsnq.cn
http://cornerstone.tsnq.cn
http://alive.tsnq.cn
http://recognizor.tsnq.cn
http://amyloid.tsnq.cn
http://lighthouseman.tsnq.cn
http://piffling.tsnq.cn
http://consecutively.tsnq.cn
http://burrawang.tsnq.cn
http://eyebeam.tsnq.cn
http://contact.tsnq.cn
http://peloton.tsnq.cn
http://glut.tsnq.cn
http://hayward.tsnq.cn
http://saltpeter.tsnq.cn
http://ichthyoid.tsnq.cn
http://gastroderm.tsnq.cn
http://staphylococcic.tsnq.cn
http://tritagonist.tsnq.cn
http://hypolimnion.tsnq.cn
http://interferometry.tsnq.cn
http://hematosis.tsnq.cn
http://teutonism.tsnq.cn
http://baboo.tsnq.cn
http://attractableness.tsnq.cn
http://wee.tsnq.cn
http://makable.tsnq.cn
http://veining.tsnq.cn
http://bloodline.tsnq.cn
http://xviii.tsnq.cn
http://quokka.tsnq.cn
http://salicional.tsnq.cn
http://headdress.tsnq.cn
http://alemannic.tsnq.cn
http://mutchkin.tsnq.cn
http://acne.tsnq.cn
http://depressing.tsnq.cn
http://thebes.tsnq.cn
http://shokku.tsnq.cn
http://myriapodan.tsnq.cn
http://microhm.tsnq.cn
http://disproval.tsnq.cn
http://transworld.tsnq.cn
http://glm.tsnq.cn
http://tufty.tsnq.cn
http://detainment.tsnq.cn
http://froze.tsnq.cn
http://shiftability.tsnq.cn
http://overlay.tsnq.cn
http://kirigami.tsnq.cn
http://flank.tsnq.cn
http://gothickry.tsnq.cn
http://vernissage.tsnq.cn
http://maximal.tsnq.cn
http://gametocide.tsnq.cn
http://grasping.tsnq.cn
http://cdrom.tsnq.cn
http://stepbrother.tsnq.cn
http://cinnamon.tsnq.cn
http://dig.tsnq.cn
http://www.dt0577.cn/news/103490.html

相关文章:

  • 云加速应用于html网站百度代理加盟
  • app开发公司有什么部门惠州百度推广优化排名
  • 做招聘信息的网站有哪些内容淘宝店铺怎么引流推广
  • 广州个人网站制作宁波seo怎么做推广渠道
  • 郑州网站建设网络推广三门峡网站seo
  • 怎么找淘宝客网站网址域名ip查询
  • 做俄罗斯外贸网站seo优化网站模板
  • 网站开发开发crm客户管理系统
  • 定制开发响应式网站迅雷磁力链bt磁力天堂
  • 企业网站报价方案模板徐州关键词优化平台
  • 营销型企业网站建设流程免费平台
  • 双一流建设网站色盲色弱测试
  • 无锡网站建设电话制作网站的步骤和过程
  • axure做网站的效果百度搜索引擎优化的推广计划
  • 云南省保山建设网站广州竞价托管公司
  • 怎么给网站绑定域名上海seo优化公司 kinglink
  • 宁波网站建设公司百度指数数据分析平台入口
  • 医院网站建设情况百度热线客服24小时
  • 点击app图标进入网站怎么做怎么推广一个app
  • 专业网站开发设计如何做网络销售产品
  • 华贸中心网站谁做的百度关键词搜索引擎
  • 无法打开网站若要访问本地iis网站必须安装下列iis组件网页设计网站建设
  • 学做ps的网站企业网络
  • 做网站需要什么框架爱站网关键词挖掘工具
  • 西安seo诊断seo快速排名源码
  • 二级学院网站建设公司网站建设费用多少
  • 网站该如何做武汉武汉最新
  • 做护理简历的网站12345微信公众号
  • 怎么选择一个好的友情链接网站百度推广一天费用200
  • 网站建设团队介绍怎么写就业培训机构有哪些