++符号在编程代码中意味着什么?

时间:2016-01-16 01:49:32

标签: javascript

此代码中++符号的含义是什么:

for (var i=0; i < myString.length; i++) {
    alert(myString[i]);
}

while (x>y) {
    alert ("xrules!");
    y++;
}

2 个答案:

答案 0 :(得分:0)

这是increment运营商。这是(almost)相当于说i = i + 1

请注意,python中不存在增量运算符,您必须编写完整的东西或使用添加赋值运算符i += 1

请注意,有post(i++)和pre(++i)增量运算符,以及等效减量运算符--i i--。这些运算符在应用增量时有所不同,并且通常是新程序员感到沮丧的原因。

答案 1 :(得分:0)

++是增量运算符

y = y + 1

和说

是一回事
<LinearLayout
    android:id="@+id/layout_small_rectancle"
    android:layout_width="match_parent"
    android:layout_height="@dimen/drv3lite_small_rectangle_height"
    android:baselineAligned="false"
    android:layout_centerVertical="true"
    android:orientation="horizontal" >

    <!-- Small rectangles. Defines the whole width -->
    <RelativeLayout 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center" 
        android:orientation="vertical" >

        <!-- Small rectangle (left) -->
        <RelativeLayout 
            android:layout_width="@dimen/drv3lite_small_rectangle_width"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/lblValueLTE"
                android:layout_width="match_parent" 
                android:layout_height="match_parent"
                android:gravity="center"
                android:textColor="@color/color_green"
                android:textSize="@dimen/drv3lite_small_rectangle_text_size"
                android:textStyle="bold"
                android:text="1317" 
                android:enabled="true"
                android:background="@drawable/selector_drv3lite_round_corners_lte"/>

            <!-- Tag indicator -->          
            <TextView
                android:id="@+id/lblTagLTE"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:gravity="start" 
                android:layout_marginLeft="5sp" 
                android:layout_marginStart="5sp"    
                android:textColor="@color/color_green"
                android:textSize="18sp"
                android:textStyle="bold"
                android:text="T" />

            <!-- Units -->          
            <TextView
                android:id="@+id/lblUnitsLTE"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:layout_alignParentBottom="true"
                android:gravity="end"
                android:layout_marginRight="5sp"    
                android:layout_marginEnd="5sp"  
                android:textColor="@color/color_green"
                android:textSize="18sp"
                android:textStyle="bold"
                android:text="&#181;V/m" />                                     
        </RelativeLayout>
    </RelativeLayout>
    <!-- Small rectangles. Defines the whole width -->
    <RelativeLayout 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center" >

        <!-- Small rectangle (right) -->                        
        <RelativeLayout 
            android:layout_width="@dimen/drv3lite_small_rectangle_width"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/lblValueMid"
                android:layout_width="match_parent" 
                android:layout_height="match_parent"
                android:gravity="center"
                android:textColor="@color/color_orange"
                android:textSize="@dimen/drv3lite_small_rectangle_text_size" 
                android:textStyle="bold"
                android:text="145" 
                android:enabled="true"
               android:background="@drawable/selector_drv3lite_round_corners_mid"/>

            <!-- Tag indicator -->          
            <TextView
                android:id="@+id/lblTagMid"
                android:layout_width="30sp" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:gravity="start" 
                android:layout_marginLeft="5sp" 
                android:layout_marginStart="5sp"    
                android:textColor="@color/color_orange"
                android:textSize="18sp"
                android:textStyle="bold"
                android:text="T" />

            <!-- Units -->          
            <TextView
                android:id="@+id/lblUnitsMid"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:layout_alignParentBottom="true"
                android:gravity="end"
                android:layout_marginRight="5sp"    
                android:layout_marginEnd="5sp"  
                android:textColor="@color/color_orange"
                android:textSize="18sp"
                android:textStyle="bold"
                android:text="&#181;V/m" />
        </RelativeLayout>               
    </RelativeLayout>               
</LinearLayout>