Tutorialspoint

Python Number abs() method

#!/usr/bin/python

print "abs(-45) : ", abs(-45)
print "abs(100.12) : ", abs(100.12)
print "abs(119L) : ", abs(119L)

Java Arrays Sort Super Index

package com.tutorialspoint;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;

public class ArrayDemo {
   public static void main(String[] args) {

      // initializing unsorted short array
      Short sArr[] = new Short[]{3, 13, 1, 9, 21};

      // let us print all the elements available in list
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }

      // create a comparator
      Comparator<Short> comp = Collections.reverseOrder();

      // sorting array with reverse order using comparator from 0 to 2
      Arrays.sort(sArr, 0, 2, comp);

      // let us print all the elements available in list
      System.out.println("short array with some sorted values(1 to 4) is:");
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }
   }
}

Java Arrays Sort Super

package com.tutorialspoint;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;

public class ArrayDemo {
   public static void main(String[] args) {

      // initializing unsorted short array
      Short sArr[] = new Short[]{3, 13, 1, 9, 21};

      // let us print all the elements available in list
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }

      // create a comparator
      Comparator<Short> comp = Collections.reverseOrder();

      // sorting array with reverse order using comparator
      Arrays.sort(sArr, comp);

      // let us print all the elements available in list
      System.out.println("short array with some sorted values(1 to 4) is:");
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }
   }
}

D3JS Selection by ID Program

<!DOCTYPE html>
<html>
   <head>
      <script type = "text/javascript" src = "https://d3js.org/d3.v4.min.js"></script>
   </head>

   <body>
      <div id = "hello">
         Hello World!
      </div>
      
      <script>
         alert(d3.select("#hello").text());
      </script>
   </body>
</html>

Java Arrays Sort Short Index

package com.tutorialspoint;

import java.util.Arrays;

public class ArrayDemo {
   public static void main(String[] args) {

      // initializing unsorted short array
      short sArr[] = {3, 13, 1, 9, 21};

      // let us print all the elements available in list
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }
      
      // sorting array from index 1 to 4
      Arrays.sort(sArr, 1, 4);

      // let us print all the elements available in list
      System.out.println("short array with some sorted values(1 to 4) is:");
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }
   }
}

Java Arrays Sort Short

package com.tutorialspoint;

import java.util.Arrays;

public class ArrayDemo {
   public static void main(String[] args) {

      // initializing unsorted short array
      short sArr[] = {22, 10, 9, 62, 5};

      // let us print all the elements available in list
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }

      // sorting array
      Arrays.sort(sArr);

      // let us print all the elements available in list
      System.out.println("The sorted short array is:");
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }
   }
}

Go Bitwise Operators

package main

import "fmt"

func main() {
   var a uint = 60	/* 60 = 0011 1100 */  
   var b uint = 13	/* 13 = 0000 1101 */
   var c uint = 0          

   c = a & b       /* 12 = 0000 1100 */ 
   fmt.Printf("Line 1 - Value of c is %d\n", c )

   c = a | b       /* 61 = 0011 1101 */
   fmt.Printf("Line 2 - Value of c is %d\n", c )

   c = a ^ b       /* 49 = 0011 0001 */
   fmt.Printf("Line 3 - Value of c is %d\n", c )

   c = a << 2     /* 240 = 1111 0000 */
   fmt.Printf("Line 4 - Value of c is %d\n", c )

   c = a >> 2     /* 15 = 0000 1111 */
   fmt.Printf("Line 5 - Value of c is %d\n", c )
}

D3JS Select by Class Program

<!DOCTYPE html>
<html>
   <head>
      <script type = "text/javascript" src = "https://d3js.org/d3.v4.min.js"></script>
   </head>

   <body>
      <div class = "myclass">
         Hello World!
      </div>
      
      <script>
         alert(d3.select(".myclass").text());
      </script>
   </body>
</html>

Python Pass Statement

#!/usr/bin/python

for letter in 'Python': 
   if letter == 'h':
      pass
      print 'This is pass block'
   print 'Current Letter :', letter

print "Good bye!"

Java Arrays Sort Object Index

package com.tutorialspoint;

import java.util.Arrays;

public class ArrayDemo {
   public static void main(String[] args) {

      // initializing unsorted Object array
      Object ob[] = {27, 11, 5, 44};

      // let us print all the elements available in list
      for (Object number : ob) {
         System.out.println("Number = " + number);
      }

      // sorting array from index 1 to 3
      Arrays.sort(ob, 1, 3);

      // let us print all the elements available in list
      System.out.println("Object array with some sorted values(1 to 3) is:");
      for (Object number : ob) {
         System.out.println("Number = " + number);
      }
   }
}

Advertisements
Loading...