目录

int hashCode()

描述 (Description)

java.io.FileOutputStream.hashCode()方法返回此对象的哈希码值。

声明 (Declaration)

以下是java.io.FilePermission.hashCode()方法的声明 -

public int hashCode()

参数 (Parameters)

NA

返回值 (Return Value)

此方法返回此对象的哈希码值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.io.FilePermission.hashCode()方法的用法。

package com.iowiki;
import java.io.FilePermission;
import java.io.IOException;
public class FilePermissionDemo {
   public static void main(String[] args) throws IOException {
      FilePermission fp = null;
      try {
         // create new file permissions
         fp = new FilePermission("C://test.txt", "read");
         // the hash code value
         int hash = fp.hashCode();
         // prints
         System.out.print("Hash Code: "+hash);
      } catch(Exception ex) {
         // if an error occurs
         ex.printStackTrace();
      }
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

Hash Code: 0
↑回到顶部↑
WIKI教程 @2018