Why do you not declare several variables of the same type on the same line?

后端 未结 16 2215
梦谈多话
梦谈多话 2020-12-06 05:41

Why is it bad practice to declare variables on one line?

e.g.

private String var1, var2, var3

instead of:

private          


        
16条回答
  •  既然无缘
    2020-12-06 05:45

    while attempting this question https://www.interviewbit.com/problems/remove-element-from-array/

    Method 1 gives Memory Limit exceeded for this code:

    Type 1:

    int i,j;
    

    Type 2:

    int i;
    int j;
    

    type 1: Gives Memory Limit Exceeded

    int removeElement  (int* A, int n1, int B) 
    {
        int k=0, i;
        for(i=0;i

    Whereas type 2 works perfectly fine

    int removeElement  (int* A, int n1, int B) 
    {
        int k=0;
        int i;
        for(i=0;i

提交回复
热议问题