);//output The value of an array element individually the } + } - } the Bayi /** the * foreach output three-dimensional array the */ - Public voidtestArray3 () { - intArr[][][] = { the{{1, 2}, {3, 4}}, the{{5, 6}, {7, 8}} the }; the -SYSTEM.OUT.PRINTLN ("----4----foreach output three-dimensional array test"); the for(int[] a2:arr) { the for(int[] a1:a2) { the for(in
, that's the difference between running time. The i++ statement in Java requires a temporary variable to fetch the value before the increment, and ++i does not need it. This causes the system to request a memory space first when using i++, then plug the value into it, and then release it at last. This is a series of operating time.We can chew on the beginning of this sentence: ++i is the first to execute i = i +1 and then use the value of I, and i++ is first using the value of I and then execute
defining a method, you do not know that you can use a variable parameter when you define several parameters - * 2. Format: the * Modifier return value type method name (data type ... Variable name)Bayi * the * 3. Precautions: the * This mutable parameter is essentially an array - * If there are multiple parameters, the variable parameter must be placed in the last - */ the Public Static voidMain (string[] args) { the the int[] arr = {11, 22, 33, 44}; the //p
Conditional judgment and indentation, note colonAdd Times limit#猜数字Lucky_num = 19Input_num =-1#次数限制Count = 0#while Lucky_num!=input_num and Count While Count input_num = Int (input ("Please input your Lucky_num:"))If Input_num Print ("Please input big num")Elif input_num > Lucky_num:Print ("Please input little num")ElsePrint ("Great")BreakCount + = 1Print (count)ElsePrint ("Too many counts!!!!")Note Indentation, Python is a language that is sensitive to indentationNote: ctrl+/For loop#次数限制For I
JS variable name: Use var to define variables, JS unified use Var to define numbers (integers, decimals), String, Boolean type, Undefined,null.General syntax: var variable name = value;Rules: 1, the initial letter is suggested to start with the English letter, _,$, can not use numbers and special characters (such as.,?)2, the second place can use letters, _,$, numbers3, cannot use the system keyword, reserved word as variable name (for example For,while .... )JS Data type: Number (integer, decim
This article translates the JavaScript Tutorial playlist of up master Kudvenkat on YouTubeSOURCE Address here:https://www.youtube.com/watch?v=PMsVM7rjupUlist=PL6n9fhu94yhUA99nOsJkKXBqokT3MBK0bIn this video we will use examples to discuss the Do-while loop in JavaScript, in Chapter 16 we discuss the while loopWhile loop:1.while Loop First Check condition2. If the condition is true, the statement in the loop executes3. This order repeats until the condition is false.Do-while Cycle:1.do-while Cycle
For loopfor var in list;Docommands, #使用变量 $varDoneExampleFor I in {A.. Z}; do actions; DoneLatterFor ((i=0;i{Commands}While conditionDoCommandsDoneUntil cycleExamplex=0;Until [$x-eq 9];DoLet x + +; echo $x;DoneIf comparison statementif contions;ThenCommandsIfelse if and ELSE statementsif condition;ThenCommandselse if Conditon;thenCommandsElseCommandsFiSimple usage:[Condition] action;[Condition] | | ActionArithmetic comparison:[$var-eq 0][$var-ne 0]Logical AND Logical OR[$var 1-ne 0-a $var 2-gt
Based on the new features of JDK5, use a for loop map, such as the Key for loop map
123
for(String dataKey : paraMap.keySet()) {System.out.println(dataKey );}
Note how paramap is defined, if it is a simple map paramap = new HashMap (); The string in front can only be converted to object.The key and value of the entire map
123456789101112
Mapnew LinkedHashMapmap.put(1,"星期一");map.put(2,"星期二");map.put(3,"星期三");map.put(4,"星期四");map.put(5,"星期五");map.pu
1PHP2 $two=Array(Array(2,3),1=>Array(,2=>)Array(4,5,6));3 Echo $two[1] [0];//Output 14 Echo $two[0] [0];//Output 25 Echo"\ r \ n";6 foreach($two as $key=$value)//Two-dimensional cyclic output7 {8 Echo $value;9 Echo"\ r \ n";Ten foreach($value as $key=$value) One { A Echo $value." \ r \ n ";//use + number error - } - } the?>PHP "+" is used as an operation, the result of the operation must be a value, and not like JS ins
Python learning [13th] condition and circular if statement single if statementThe IF statement has three parts, the keyword if itself, the conditional expression that determines whether the result is true, and whether the expression is real or not 0 is the code that executesIf expression:Expr_true_suiteThe conditional expression can be multiple by using the Boolean operator and or not to implement theIf code block for a single statement, if the execution code of the IF statement has only one lin
1 classNode ():2 def __init__(self,item=None):3Self.item =Item4Self.next =None5 6 #def Doselinklistcontainsloop (head):7 #if head = = None:8 #print ("is an empty list")9 #return FalseTen #slowptr = Head One #fastptr = Head A #While Fastptr.next!=none and Fastptr.next.next!=none: - #slowptr = Slowptr.next - #fastptr = FastPtr.next.next the #if slowptr = = fastptr: - #print ("A linked list of ring structures") - #return True - #print ("Not a linked list of ring structures") + #return False -
++5 if sum>3:6 break # exits the loop bodyThis is a simple small example, when the value of sum reaches 3 and exits directly, very well understood.The use of continue The role of continue is also the exit loop, but he is different from break, is directly out of the loop, and he just quit the loop and then go to execute the next time, the difference is that one is completely out of the loop, one is only introduced this cycle.For example:1 num=02 while True:3 num+=14 if num%2=
Conditions and loopsConditional execution:Name = Raw_input (' What's your name? ' If Name.endswith (' Gumby '):p rint ' Hello, Mr.gumby 'What is your name? Gumbyhello, Mr.gumbyName = Raw_input (' What's your name? ' If Name.endswith (' Gumby '):p rint ' Hello, mr.gumby ' else:print ' Hello, stranger 'Multiple conditions:num = input (' Enter a number: ') if num > 0:print ' The number is positive ' elif num Enter a number:5the number is positiveEnter A number: -1the number is negativeEnter a numbe
); //set up the table headerqstringlist headers; Headers" Section number""Title""Page Number"; Treewidget-setheaderlabels (headers); //The loop executes six times altogether for(intI=0; isizeof(directory)/sizeof(directory[0]); i++) {Sectioninfo info= Directory[i];//Assigning a value to a C + + struct is quite ingenious.Qtreewidgetitem * item=NULL; if(strcmp (info.parent_id,"")==0) {Item=NewQtreewidgetitem (Treewidget);//set a line attached to the whole}Else{QString parent_id (info.parent_id)
1 selectionIf elif ElseNote that the following are:if age>18: print'adult'elif age>6: Print ' teenager ' Else : Print ' Kid '2 Cycles1) for x in XX:names = ['Michael'Bob'Tracy ' ] for in names: Print name2) while XX:sum == while n > 0: = sum + n = n-2print sum3) Advanced Range (A,B,C), a start, b termination (not including B), C stepPrint sum (range (1,100,2))3 Break and ContinueBreak causes the entire loop to end prematurelyContinue terminates this loop, ignores all statemen
1. Judgment and CirculationPython indentMainPrint ("Hello")Print ("Hello world.")if 判断条件: 执行语句elif 判断条件: 执行语句else: 执行语句while 判断条件: 执行语句a = 100while a>1: print(a) a-=1 if a==50: break # 退出循环 if a==55: print("5555555555") continue # 此次循环结束,进入下一个循环Break jumps out of the loopContinue into the next cyclefor item in sequence: 执行语句l = ["a","b","c","d","e","f"]print(l[:])print(l[0:5]) # 大于等于0 小于5 0 2, the programming idea is the most importa
1.some (): Returns a Boolean that determines if an element meets the Func conditionConst ARR = [1,2,3,4]; Arr.some (item) =>{return item>1})Print Result: True2.every (): Returns a Boolean that determines whether each element conforms to the Func conditionConst ARR1 = [1,2,3,4]; Arr.every (item) =>{return item>3});Printing results:False3.filter (): Returns an array of elements that conform to the Func conditionlet ages = [33,44,55,66,77]; Ages.filter (item) =>{return item>18})Printed results [33,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.