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

自己做网站制作教程最近一周新闻热点回顾

自己做网站制作教程,最近一周新闻热点回顾,厦门网站设计公司,网站平面设计java.nio.IntBuffer类的duplicate()方法用于创建一个新的IntBuffer,它在所有方面都相同地共享给定缓冲区的内容。用法:public abstract IntBuffer duplicate()返回值:此方法返回新的IntBuffer,它携带以前的IntBuffer的内容下面是说明duplicat…

java.nio.IntBuffer类的duplicate()方法用于创建一个新的IntBuffer,它在所有方面都相同地共享给定缓冲区的内容。

用法:

public abstract IntBuffer duplicate()

返回值:此方法返回新的IntBuffer,它携带以前的IntBuffer的内容

下面是说明duplicate()方法的示例:

范例1:使用直接IntBuffer

// Java program to demonstrate duplicate() method

import java.nio.*;

import java.util.*;

public class GFG {

public static void main(String[] args)

{

// Declaring the capacity of the IntBuffer

int capacity = 10;

// Creating the IntBuffer

try {

// creating object of Intbuffer

// and allocating size capacity

IntBuffer ib1 = IntBuffer.allocate(capacity);

// putting the value in Intbuffer

ib1.put(8);

ib1.put(2, 9);

ib1.rewind();

// print the Original IntBuffer

System.out.println("Original IntBuffer:  "

+ Arrays.toString(ib1.array()));

// Creating a duplicate copy of IntBuffer

// using duplicate() method

IntBuffer ib2 = ib1.duplicate();

// print the duplicate copy of IntBuffer

System.out.print("Duplicate IntBuffer: "

+ Arrays.toString(ib2.array()));

}

catch (IllegalArgumentException e) {

System.out.println("IllegalArgumentException catched");

}

catch (ReadOnlyBufferException e) {

System.out.println("ReadOnlyBufferException catched");

}

}

}

输出:

Original IntBuffer: [8, 0, 9, 0, 0, 0, 0, 0, 0, 0]

Duplicate IntBuffer: [8, 0, 9, 0, 0, 0, 0, 0, 0, 0]

范例2:使用read-onlyintbuffer

// Java program to demonstrate

// duplicate() method

// using read-onlyIntbuffer

import java.nio.*;

import java.util.*;

public class GFG {

public static void main(String[] args)

{

// Declaring the capacity of the IntBuffer

int capacity = 10;

// Creating the IntBuffer

try {

// creating object of Intbuffer

// and allocating size capacity

IntBuffer ib1 = IntBuffer.allocate(capacity);

// putting the value in Intbuffer

ib1.put(8);

ib1.put(2, 9);

ib1.rewind();

// print the Original IntBuffer

System.out.println("Original IntBuffer:  "

+ Arrays.toString(ib1.array()));

// Creating a read-only copy of IntBuffer

// using asReadOnlyBuffer() method

IntBuffer readonly = ib1.asReadOnlyBuffer();

// print the read-only copy of IntBuffer

System.out.print("read-only IntBuffer:  ");

while (Readonly.hasRemaining())

System.out.print(readonly.get() + ", ");

System.out.println("");

// Rewinding the readonly IntBuffer

readonly.rewind();

// Creating a duplicate copy of IntBuffer

// using duplicate() method

IntBuffer ib2 = readonly.duplicate();

// print the duplicate copy of IntBuffer

System.out.print("Duplicate copy of read-only IntBuffer:  ");

while (ib2.hasRemaining())

System.out.print(ib2.get() + ", ");

System.out.println("");

}

catch (IllegalArgumentException e) {

System.out.println("IllegalArgumentException catched");

}

catch (ReadOnlyBufferException e) {

System.out.println("ReadOnlyBufferException catched");

}

}

}

输出:

Original IntBuffer: [8, 0, 9, 0, 0, 0, 0, 0, 0, 0]

Read-only IntBuffer: 8, 0, 9, 0, 0, 0, 0, 0, 0, 0,

Duplicate copy of read-only IntBuffer: 8, 0, 9, 0, 0, 0, 0, 0, 0, 0,

http://www.lbrq.cn/news/2688553.html

相关文章:

  • 网站做记录访客故事式软文范例500字
  • 专业设计网站推荐螺蛳粉营销策划方案
  • 东莞厚街有什么好玩的地方seo实战培训费用
  • 广东品牌女装都有哪些品牌seo关键技术有哪些
  • jsp网站开发实例标题栏江西seo推广方案
  • 中建铁路建设有限公司网站短视频营销常用平台有
  • 网站测试软件广告软文范例
  • 正品海外购网站有哪些怎样和政府交换友链
  • 做网站首页的尺寸专业整站优化
  • 云职上海企业服务有限公司做网络优化的公司排名
  • 做网站图片分辨率优化是什么意思?
  • 一站式网站建设与运营风云榜小说排行榜
  • 电子产品网站建设 实训报告南京seo排名优化
  • 开封网站优化公司危机公关处理方案
  • 瑞丽住建局网站推文关键词生成器
  • 商丘做网站用什么程序网站维护
  • 网站上传用什么软件做视频格式广告优化师
  • 网站上传的图片怎么做的清晰度网站seo关键词排名
  • 做淘宝客优惠券网站必须是企业吗网站测速
  • 网站制作与维护费用seo关键词排名优化工具
  • 做企业平台的网站有哪些内容抖音seo优化软件
  • 莱芜公司做网站专业做网站建设的公司
  • 辽宁地矿建设集团有限公司网站合肥关键词排名提升
  • 浙江省住房和建设厅网站全国各城市感染高峰进度查询
  • 高端做网站价格查询网站域名
  • 推动全省政府网站建设百度北京分公司官网
  • 技术社区网站开发软件培训机构排名
  • 四川电脑网站建设厦门网站seo
  • 查企业营业执照的网站查询域名网站
  • 莆田个人外贸网站建设游戏推广员每天做什么
  • 过程设计工具深度解析-软件工程之详细设计(补充篇)
  • 【跨服务器的数据自动化下载--安装公钥,免密下载】
  • css之再谈浮动定位float(深入理解篇)
  • FinQ4Cn: 基于 MCP 协议的中国 A 股量化分析
  • 贪心----3. 跳跃游戏 II
  • 常用设计模式系列(十九)- 状态模式