如果Serializable接口只是一个标记接口,用于传递有关java中类的元数据 - 我有点困惑:
在阅读了java的序列化算法(元数据从下到上,然后是从上到下的实际实例数据)的过程之后,我无法真正理解通过该算法无法处理哪些数据.
简而言之:
NotSerializableException?implements Serializable为我的课程添加条款?前言: 我对结构对齐的研究.看着这个问题,这一个也是这个 - 但仍然没有找到我的答案.
我的实际问题:
这是我创建的代码片段,以澄清我的问题:
#include "stdafx.h"
#include <stdio.h>
struct IntAndCharStruct
{
int a;
char b;
};
struct IntAndDoubleStruct
{
int a;
double d;
};
struct IntFloatAndDoubleStruct
{
int a;
float c;
double d;
};
int main()
{
printf("Int: %d\n", sizeof(int));
printf("Float: %d\n", sizeof(float));
printf("Char: %d\n", sizeof(char));
printf("Double: %d\n", sizeof(double));
printf("IntAndCharStruct: %d\n", sizeof(IntAndCharStruct));
printf("IntAndDoubleStruct: %d\n", sizeof(IntAndDoubleStruct));
printf("IntFloatAndDoubleStruct: %d\n", sizeof(IntFloatAndDoubleStruct));
getchar();
}
Run Code Online (Sandbox Code Playgroud)
它的输出是:
Int: 4
Float: 4
Char: 1
Double: 8
IntAndCharStruct: 8
IntAndDoubleStruct: 16 …Run Code Online (Sandbox Code Playgroud)