首页 > 其他分享 >Method Demo02

Method Demo02

时间:2023-10-22 13:01:48浏览次数:24  
标签:return int double sum public Demo02 result Method

package com.chen.method;

public class Demo02 {
public static void main(String[] args) {
double sum = sum(1.0, 1.0);
System.out.println(sum);

}
//比大小
public static double sum(double a,double b) {
double result = 0;

if (a == b) {
System.out.println("a==b");
return 0;//终止方法
}

if (a > b) {
result = a;
} else {
result = b;
}
return result;
}

//比大小
public static int sum(int a,int b){
int result = 0;

if(a==b){
System.out.println("a==b");
return 0;//终止方法
}

if(a>b){
result = a;
}else {
result = b;
}
return result;
}
}

标签:return,int,double,sum,public,Demo02,result,Method
From: https://www.cnblogs.com/jingyichenloveningning/p/17780306.html

相关文章

  • Method Demo01
    packagecom.chen.method;publicclassDemo01{//main方法publicstaticvoidmain(String[]args){intsum=add(1,2,3);System.out.println(sum);//test();}//加法publicstaticintadd(inta,intb){returna+......
  • 【PowerShell】Invoke-WebRequest和Invoke-RestMethod
    ##PublicfreeRestfulAPIURL ##https://documenter.getpostman.com/view/8854915/Szf7znEe#intro#Example01#--------------------------------------------------------------$url="https://cat-fact.herokuapp.com/facts/"$r=Invoke-WebReques......
  • Struct IfDemo02
    packagecom.chen.struct;importjava.util.Scanner;publicclassIfDemo02{publicstaticvoidmain(String[]args){//考试分数大于60分就是及格,小于60分就是不及格。Scannerscanner=newScanner(System.in);System.out.println("请输入成......
  • Struct SwitchDemo02
    packagecom.chen.struct;publicclassSwitchDemo02{publicstaticvoidmain(String[]args){Stringname="种崎敦美";//JDK7的新特性,表达式结果可以是字符串!!!//字符的本质还是数字//反编译Java----class(字节码文件)-----反编译(ID......
  • Struct DoWhileDemo02
    packagecom.chen.struct;publicclassDoWhileDemo02{publicstaticvoidmain(String[]args){inta=0;while(a<0){System.out.println(a);a++;}System.out.println("==============");......
  • IDEA 出现 Cannot resolve method getParameter() in JSP 解决方法
    原链接java-CannotresolvemethodgetParameter()inJSP-StackOverflowIDEA中出现下图情况,版本IDEA2022.2.3。此方法大概率可用,如果帮到你请点个赞吧~  1.我们右键当前项目,选择进入"OpenModuleSettings",如下图2.进入下图界面后,点击下图加号弹出二级菜单,在通......
  • [914] In Python's datetime library, you can format dates using the strftime() me
    InPython'sdatetimelibrary,youcanformatdatesusingthestrftime()method.Thismethodallowsyoutocreateaformattedstringrepresentationofadatetimeobject,specifyingtheformatyouwant.Here'showyoucanformatadateusingstrft......
  • Program does not contain a static 'Main' method suitable for an entry point
    http://www.kangry.net/blog/?article_id=391&type=article修改办法,对着项目右键-》属性-》application-》outputtype设为ClassLibrary即可。  ......
  • [905] The replace() method in Pandas
    InPandas,thereplace()methodisusedtoreplacevaluesinaDataFrameorSeries.Youcanusethismethodtoreplaceoneormorespecifiedvalueswithothervalues.Here'showyoucanuseit:Syntax:DataFrame.replace(to_replace,value,inplace=Fal......
  • 核方法(kernel method)的主要思想
    本文对核方法(kernelmethod)进行简要的介绍(https://www.jianshu.com/p/8e2649a435c4)。核方法的主要思想是基于这样一个假设:“在低维空间中不能线性分割的点集,通过转化为高维空间中的点集时,很有可能变为线性可分的”,例如下图   左图的两类数据要想在一维空间上线性分开......