Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Kod pro Dana

import 	java.nio.ByteBuffer;
import java.nio.IntBuffer;

public class HelloWorld{

     public static void main(String []args){
        int[] pole_int = new int[] {9, 1, 53, 2, 0};
        
        // Konverze int[] na byte[]
        ByteBuffer byteBuffer = ByteBuffer.allocate(pole_int.length * 4);
        IntBuffer intBuffer = byteBuffer.asIntBuffer();
        intBuffer.put(pole_int);
        byte[] pole_byte = byteBuffer.array();
        
        // Konverze byte[] na int[]
        int[] pole_int_2 = convertToIntArray(pole_byte);
        
        
        // Konverze poli na string - pro print
        StringBuilder sb = new StringBuilder();
        for (Integer integer : pole_int) {
            sb.append(integer);
        }
        String pole_int_string = sb.toString();
        
        System.out.println("puvodni : " + pole_int_string);
        
        
        StringBuilder sb_2 = new StringBuilder();
        for (Integer integer : pole_int_2) {
            sb_2.append(integer);
        }
        String pole_int_2_string = sb_2.toString();
        
        System.out.println("po konverzi : " + pole_int_2_string);
        
        
     }
     
     public static int[] convertToIntArray(byte[] input)
    {
        int[] ret = new int[input.length];
        for (int i = 0; i < input.length; i++)
        {
            ret[i] = input[i] & 0xff; // Range 0 to 255, not -128 to 127
        }

        return ret;
    }
}

Kod pro Dana

import 	java.nio.ByteBuffer;
import java.nio.IntBuffer;

public class HelloWorld{

     public static void main(String []args){
        int[] pole_int = new int[] {9, 1, 53, 2, 0};
        
        // Konverze int[] na byte[]
        ByteBuffer byteBuffer = ByteBuffer.allocate(pole_int.length * 4);
        IntBuffer intBuffer = byteBuffer.asIntBuffer();
        intBuffer.put(pole_int);
        byte[] pole_byte = byteBuffer.array();
        
        // Konverze byte[] na int[]
        int[] pole_int_2 = convertToIntArray(pole_byte);
        
        
        // Konverze poli na string - pro print
        StringBuilder sb = new StringBuilder();
        for (Integer integer : pole_int) {
            sb.append(integer);
        }
        String pole_int_string = sb.toString();
        
        System.out.println("puvodni : " + pole_int_string);
        
        
        StringBuilder sb_2 = new StringBuilder();
        for (Integer integer : pole_int_2) {
            sb_2.append(integer);
        }
        String pole_int_2_string = sb_2.toString();
        
        System.out.println("puvodni : " + pole_int_2_string);
        
        
     }
     
     public static int[] convertToIntArray(byte[] input)
    {
        int[] ret = new int[input.length];
        for (int i = 0; i < input.length; i++)
        {
            ret[i] = input[i] & 0xff; // Range 0 to 255, not -128 to 127
        }

        return ret;
    }
}

Compile and Execute Java Online

package integrationtestingchallenge;

public class Integrationtestingchallenge {

    public static void main(String[] args) {
        int month, day, year;
        System.out.println("welcome to nextdate");
        year = 1600; //nilai yang diubah
        System.out.println(isLeap(year));

    }

    public static boolean isLeap(int year) { //8
        if (year % 4 == 0) { //9
            if (year % 100 != 0) { //10=then pada pseudocode 11=if
                return true; //12
            } else {//13
                if (year % 400 == 0) {//14
                    return true; //15
                } else { //16
                    return false;
                }
            }//17
        } //18
        return false; //19
    } //20 

} //21

Compile and Execute Java Online

import java.util.*;

public class HelloWorld{
    
    static int matrix[][]; 
    static int count = 0;
    
    public static void main(String []args){
        Scanner kb = new Scanner(System.in);
        
        int n = kb.nextInt();
        int val[] = new int[n];
        int cost[] = new int[n]; 
        
        for(int i = 0; i < n; i++) {
            val[i] = kb.nextInt(); 
        }
        
        for(int i = 0; i < n; i++) {
            cost[i] = kb.nextInt(); 
        }
        
        int max = kb.nextInt();
        
        matrix = new int[n][max+1];

        for(int i = 0; i < n; i++) {
            for(int j = 0; j <= max; j++) {
                if(i == 0) {
                    matrix[i][j] = j >= cost[i] ? val[i] : 0;
                    continue;
                }
                
                if(j == cost[i]) {
                    matrix[i][j] = matrix[i-1][j] <= val[i] ? val[i] :matrix[i-1][j];  
                } else if(j < cost[i]) {
                    matrix[i][j] = matrix[i-1][j];
                } else if(j > cost[i]) {
                    int curr = matrix[i-1][j-cost[i]]+val[i];
                    matrix[i][j] = curr >= matrix[i-1][j] ? curr : matrix[i-1][j];
                }
            }
        }
        
        for(int x[] : matrix) {
            for(int y : x) System.out.print(y + " ");
            System.out.println();
        }
     }
}

String concat

import java.util.Scanner;
import java.lang.String;
public class HelloWorld{

     public static void main(String []args){
       Scanner input = new Scanner(System.in);
       String a = input.nextLine();
       String b = input.nextLine();
       String c = a.concat(b);
       System.out.println(c);
       
     }
}

Primo1.1.0

public class HelloWorld{

     public static void main(String []args){
        System.out.println("sdsdsdsdsd");
     }
}

Compile and Execute Java Online

public class HelloWorld{

     public static void main(String []args){
        System.out.println("Hello World");
         Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        System.out.println("Hello World", day);
     }
     
     
}

Compile and Execute Java Online

public abstract class Expression
{
    public abstract double value();
    public abstract String toString();
}

public interface Expression
{
    double value();
    String toString();
}

Compile and Execute Java Online

public class TestPet {
    private String name;
    private String animal;
    private int feed;
    private int play;
    
    public Pet() {
        
    }

    public int getFeed();
        return feed;
   }
   
    public int getName();
        return name;
   }
   
    public String getAnimal();
        return animal;
   }
   
    public int getPlay();
        return play;
   }
   

    public void setFeed(int feed);
        this.feed = feed;
   }
   
    public void setName(String name);
        this.name = name;
   }
   
    public void setAnimal(String animal);
        this.animal = animal;
   }
   
    public void setPlay(int play);
        this.play = play;
   }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.