首页 > 其他分享 >void

void

时间:2023-05-28 11:58:07浏览次数:24  
标签:void 申明 print 返回值 方法 public

package com.karl2;

public class MethoDemo {
    public static void main(String[] args) {
        //打印6行
        print(6);
        //打印3行
        print(3);
    }
    //如果方法不需要返回数据,返回值类型必须申明成void(无返回值申明),此方法内部不可以使用return返回数据
    //方法如果不需要接受数据,则不需要定义形参,且调用方法时也不可以传数据给方法了
    //没有参数,且没有返回值类型(void)申明的方法,称无参数、返回值的方法,依次类推
    public static void print(int n){
        for (int i = 0; i <=n; i++) {
            System.out.println("kokoko");

        }
    }
}

 

标签:void,申明,print,返回值,方法,public
From: https://www.cnblogs.com/Karl-hut/p/17438010.html

相关文章

  • void
    void的用法:当要定义一个无参的函数时,只能想下面这样定义:intf(void){}//void必须写,这样才是一个无参的函数;intf(){}//这要定义不是一个无参的函数,这个函数表示可以接受任意多个函数。如:intf(){}intg(void){}f();//能正确执行f(......
  • 路由导航报错:NavigationDuplicated: Avoided redundant navigation to current locati
    跳转页面时候,重复点击菜单引起路由重复报错;点击按钮跳转到同一个或当前的路径会报错。为每一个Promise添加一个回调函数this.$router.push({name:'Cats',},()=>{})修改VueRouter原型对象上的push/replace方法在router/index.js文件中添加如下代码//获取原型对......
  • javascript:void(0)
    javascript:void(0),仅仅表示一个死链接,当href=javascript:void(0)的空链接被点击时,页面不会有任何反应。让超链接去执行一个js函数,而不是去跳转到一个地址,而void(0)表示一个空的方法,也就是不执行js函数。javascript:是伪协议,表示url的内容通过javascript执行。void(0)计算结果......
  • IE 6下 a javascript:void(0)问题
     在购物页面的“立即购买”按钮是用a标签来做的,设置了href="javascript:void(0);",同时在a上面添加了onclick事件,目的是在点击之后处理Cookies并跳转到订单页面。反复测试发现ie6下没有跳转,ff下是正常的。在网上搜到的结果是ie6的bug导致这样的结果。 摘自网络产生这样的结果是......
  • atomically try catch and avoid throw exception
    #include<assert.h>#include<atomic>#include<chrono>#include<fstream>#include<iomanip>#include<iostream>#include<numeric>#include<thread>#include<unistd.h>#include<uuid/uuid.h>......
  • [Javascript] avoid mutation: Array.prototype.toSpliced() vs splice()
    Array.prototype.splice()mutatestheoriginalarray.Toavoidmutation,weuseArray.prototype.slice().newmethodArray.prototype.toSpliced()returnanewarraytoavoidthemutation.constmonths=["Jan","Mar","Apr",&quo......
  • [Javascript] Avoid mutation, Array.prototype.toSorted() vs sort()
    sort(),mutatestheoriginalarray,andreturnthereferencetooriginalarrayandsorted.The toSorted() methodof Array instancesisthe copying versionofthe sort() method.Itreturnsanewarraywiththeelementssortedinascendingorder.const......
  • [Javascript] Avoid mutation, Array.prototype.toReversed() vs reverse()
    reverse()mutatestheoriginalarray,returnthereferencepointtotheoriginalarray.The toReversed() methodof Array instancesisthe copying counterpartofthe reverse() method.Itreturnsanewarraywiththeelementsinreversedorder.constite......
  • 使用Mockito-mock,void方法
    示例publicResponsedate(Stringurl){@ResourceprivateIRuleJudgmentServiceruleJudgmentService;//示例方法,伪代码ruleJudgmentService.ruleJudgement(参数,参数);//其他业务returnResponse;}调用的void方法publicinterfa......
  • 【c&c++】VScode报错error: ‘::main‘ must return ‘int‘ void main()
    在运行指针时终端出现error:‘::main’mustreturn‘int’voidmain()错误。源代码如下:#include<stdio.h>voidmain(){inta,*p,b,c,d,e;a=100;p=&a;/*(*&a)先进行&a运算,得a的地址,再进行*运算,即变量a的值*/b=*&a;printf("a=%d\n",a);......