---
title: "Error Collections in Java"
author: "Data168"
date: "2014-10-04T11:34:57Z"
tags: []
categories: ["编程语言"]
slug: "error-collections-in-java"
draft: false
lastmod: "2014-10-04T11:38:47Z"
id: 2124647
url: "https://data168.iteye.com/blog/2124647"
---

本文记录遇到的各种Java报错提示。

 

1.Cannot make a static reference to the non-static field  无法在静态方法中引用非静态变量 。

```
public class Test {
	byte aa;
	short bb;
	int cc;
	long dd;
	double ee;
	float ff;
	boolean gg;
	char hh;
	
	public static void main(String[] args){
		
		System.out.println("the value of aa is :" + aa);
		System.out.println("the value of aa is :" + aa);
		
	}
}
```

 把实例变量加上static修饰符就好了。

```
public class Test {
	static byte aa;
	static short bb;
	static int cc;
	static long dd;
	static double ee;
	static float ff;
	static boolean gg;
	static char hh;
	
	public static void main(String[] args){
		
		System.out.println("the value of aa is :" + aa);
		System.out.println("the value of bb is :" + bb);
		System.out.println("the value of cc is :" + cc);
		System.out.println("the value of dd is :" + dd);
		System.out.println("the value of ee is :" + ee);
		System.out.println("the value of ff is :" + ff);
		System.out.println("the value of gg is :" + gg);
		System.out.println("the value of hh is :" + hh);
				
	}
}
```