Java ObjectStreamField getTypeCode()方法与示例

news/2024/5/19 4:41:09 标签: java, http, django, redis, 反射

ObjectStreamField类的getTypeCode()方法 (ObjectStreamField Class getTypeCode() method)

  • getTypeCode() method is available in java.io package.

    getTypeCode()方法java.io包中可用。

  • getTypeCode() method is used to retrieve character code of field type.

    getTypeCode()方法用于检索字段类型的字符代码。

  • getTypeCode() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    getTypeCode()方法是一个非静态方法,只能通过类对象进行访问,如果尝试使用类名访问该方法,则会收到错误消息。

  • getTypeCode() method does not throw an exception at the time of returning type code of field.

    返回字段的类型代码时, getTypeCode()方法不会引发异常。

Syntax:

句法:

    public char getTypeCode();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is char, it returns the typecode of the serializable field.

该方法的返回类型为char ,它返回可序列化字段的类型代码。

Example:

例:

// Java program to demonstrate the example 
// of char getTypeCode() method 
// of ObjectStreamField

import java.io.*;
import java.util.*;

public class GetTypeCodeOfOSF {
 public static void main(String[] args) {
  // Instantiates ObjectStreamClass for Calendar
  ObjectStreamClass o_sc = ObjectStreamClass.lookup(Calendar.class);

  // By using getField() method is to get the field
  // value from Calendar 
  ObjectStreamField field1 = o_sc.getField("isTimeSet");
  ObjectStreamField field2 = o_sc.getField("fields");

  // By using getTypeCode() method is to return
  // the type code of the field

  char field1_typecode = field1.getTypeCode();
  System.out.println("field1.getTypeCode(): " + field1_typecode);

  char field2_typecode = field2.getTypeCode();
  System.out.println("field2.getTypeCode(): " + field2_typecode);
 }
}

Output

输出量

field1.getTypeCode(): Z
field2.getTypeCode(): [


翻译自: https://www.includehelp.com/java/objectstreamfield-gettypecode-method-with-example.aspx


http://www.niftyadmin.cn/n/1255834.html

相关文章

堆的相关操作

堆: 堆本质上就是一棵用数组存储的完全二叉树。 因此用数组存储的完全二叉树的性质,堆也具备。 性质1: 对于i结点 他的左孩子是2i 他的右孩子是2i1 性质2: 如果 2i < n ,则代表该结点没有左孩子 性质3: 如果 2i1 < n , 则代表该结点没有右孩子 …

Java ObjectOutputStream writeChars()方法与示例

ObjectOutputStream类writeChars()方法 (ObjectOutputStream Class writeChars() method) writeChars() method is available in java.io package. writeChars()方法在java.io包中可用。 writeChars() method is used to write the given string as a chain of characters. wri…

flask源码解读02: app.run()的背后(续)

前面说到通过新建Handler类来处理请求 默认情况下Handler类为WSGIRequestHandler class WSGIRequestHandler(BaseHTTPRequestHandler):server_version "WSGIServer/" __version__def get_environ(self):env self.server.base_environ.copy()env[SERVER_PROTOCOL] …

SQL SERVER:获取树形结构表的层级、索引和序号

/*新建树形结构表,id,父节点(parentid)节点层级(depth)&#xff0c;广度优先遍历索引(pathindex)&#xff0c;树结构序号(numbericalmapping) */ CREATE TABLE tree(id int NOT NULL,parentid int NULL,name nvarchar(300) NOT NULL,depth int NULL,pathindex int NULL,numeric…

java iterator_Java ArrayDeque降序Iterator()方法及示例

java iteratorArrayDeque类降序Iterator()方法 (ArrayDeque Class descendingIterator() method) descendingIterator() Method is available in java.lang package. DescendingIterator()方法在java.lang包中可用。 descendingIterator() Method is used to return an iterato…

基数排序(桶排序)

基数排序(俗称桶排序): 基数排序是一种全新的排序思想,不同于之前学的几种排序. 之前学的 直接插入排序O(n^2)、希尔排序O(n^1.3 - O^2)、 冒泡排序O(n^2)、简单选择排序O(n^2)、快速排序O(nlogn)、堆排序O(nlogn)、 归并排序O(nlogn) 这些排序都是基于交换元素的排序思想,只不…

Spring知识汇总

Spring框架是由于软件开发的复杂性而创建的。Spring使用的是基本的JavaBean来完成以前只可能由EJB完成的事情。然而&#xff0c;Spring的用途不仅仅限于服务器端的开发。从简单性、可测试性和松耦合性的角度而言&#xff0c;绝大部分Java应用都可以从Spring中受益。 Spring优点…

计算机vpu处理器_计算机科学组织| 处理器内部通讯

计算机vpu处理器内部沟通 (Internal communication) CPU of the computer system communicates with the memory and the I/O devices in order to transfer data between them. However the method of communication of the CPU with memory and I/O devices in different. Th…