小编Mor*_*ayS的帖子

Java:什么可以和什么不能序列化?

如果Serializable接口只是一个标记接口,用于传递有关java中类的元数据 - 我有点困惑:

在阅读了java的序列化算法(元数据从下到上,然后是从上到下的实际实例数据)的过程之后,我无法真正理解通过该算法无法处理哪些数据.

简而言之:

  1. 什么数据可能导致NotSerializableException
  2. 我怎么知道我不应该implements Serializable为我的课程添加条款?

java serialization marker-interfaces

24
推荐指数
4
解决办法
3万
查看次数

sizeof(),C结构中的对齐方式:

前言: 我对结构对齐的研究.看着这个问题,一个也是这个 - 但仍然没有找到我的答案.

我的实际问题:

这是我创建的代码片段,以澄清我的问题:

#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)

c struct alignment

6
推荐指数
2
解决办法
616
查看次数

标签 统计

alignment ×1

c ×1

java ×1

marker-interfaces ×1

serialization ×1

struct ×1