Computer Science, asked by arindampalkgp, 1 year ago

difference between concatenation and truncation

Answers

Answered by sancharimouri
6

Answer:

concatination simply means joining 2v things while

In simplest terms, truncation means to chop off the decimal portion of a number. This means:

Truncating 3.3 returns 3

Truncating 3.8 returns 3

here's an example for truncation

// Java program to demonstrate  

// Instant.truncatedTo() method  

import java.time.*;  

public class GFG {  

public static void main(String[] args)  

{  

 // create a Instant object  

 Instant instant  

  = Instant.parse("");  

 // print instance  

 System.out.println("Instant before"

     + " truncate: "

     + instant);  

 // truncate to ChronoUnit.HOURS  

 // means unit smaller than Hour  

 // will be Zero  

 Instant returnvalue  

  = instant.truncatedTo();  

 // print result  

 System.out.println("Instant after "

     + " truncate: "

     + returnvalue);  

}  

}  

Answered by aninditak321
1

Concatenation in Java basically joins two strings together whereas truncation trims digits , numbers or characters or blanks.

Similar questions