Nancy Den has Published 330 Articles

C++ Program to Emulate N Dice Roller

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

889 Views

Here is the code to emulate N dice roller. This can be done by generating random number between 1-6.AlgorithmBegin    Declare n    Read n    For i = 0 to n-1 do       Generate sequence with rand() mod 6 + 1       Print the sequence ... Read More

The accept() method in Java Stream.Builder

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

1K+ Views

Add an element to the stream using the accept() method of Java Stream.Builder.The following is the syntax:void accept(T t)Here, t is the argument to be inserted.Import the following package for the Stream.Builder class in Java:import java.util.stream.Stream;First, declare a Stream.Builder:Stream.Builder builder = Stream.builder();Now, use the accept() method:builder.accept("Demo"); builder.accept("Text");The following is an ... Read More

Java Program to adjust LocalDate to last Day of Year with TemporalAdjusters class

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

645 Views

Let us first set a date:LocalDate localDate = LocalDate.of(2019, Month.FEBRUARY, 11);Now, adjust LocalDate to last Day of year:LocalDate day = localDate.with(TemporalAdjusters.lastDayOfYear());Exampleimport java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjusters; public class Demo {    public static void main(String[] args) {       LocalDate localDate = LocalDate.of(2019, Month.FEBRUARY, 11);       System.out.println("Current ... Read More

Java Program to adjust LocalDate to next Tuesday with TemporalAdjusters class

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

99 Views

At first, set a LocalDate:LocalDate localDate = LocalDate.of(2019, Month.FEBRUARY, 2);Now, adjust the LocalDate to next Tuesday using next() method:LocalDate date = localDate.with(TemporalAdjusters.next(DayOfWeek.TUESDAY));Exampleimport java.time.DayOfWeek; import java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjusters; public class Demo {    public static void main(String[] args) {       LocalDate localDate = LocalDate.of(2019, Month.FEBRUARY, 2);   ... Read More

The build() method in Java LongStream.Builder

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

122 Views

The build() method of the LongStream.Builder class builds the stream and returns the built stream. The following is the syntax:LongStream build()Import the following package for the LongStream.Builder class in Java:import java.util.stream.LongStream;Declare a LongStream.Builder and add elements:LongStream.Builder builder = LongStream.builder(); builder.add(24000L); builder.add(47470L); builder.add(12999L);Now, use the build() method to build the ... Read More

I/O-mapped I/O in 8085 Microprocessor

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

4K+ Views

Generally, a processor like 8085, to address one I/O port by sending out 8-bit port address and IO/M* = 1. For example, let us say, the chip select pin of an I/O port chip is activated when 8-bit address = F0H, IO/M* = 1, and RD* = 0. This is ... Read More

MonthDay compareTo() method in Java

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

95 Views

Two MonthDay objects can be compared using the compareTo() method in the MonthDay class in Java. This method requires a single parameter i.e. the MonthDay object to be compared.If the first MonthDay object is greater than the second MonthDay object it returns a positive number, if the first MonthDay object ... Read More

MonthDay format() method in Java

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

60 Views

The MonthDay can be formatted with the specified formatter using the format() method in the MonthDay class in Java. This method requires a single parameter i.e. the MonthDay object to be formatted and it returns the formatted MonthDay with the specified formatter.A program that demonstrates this is given as followsExample Live ... Read More

MonthDay equals() method in Java

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

80 Views

The equality of two MonthDay objects can be determined using the equals() method in the MonthDay class in Java. This method requires a single parameter i.e. the MonthDay object to be compared. Also it returns true if both the MonthDay objects are equal and false otherwise.A program that demonstrates this ... Read More

Convert Character Array to IntStream in Java

Nancy Den

Nancy Den

Updated on 30-Jul-2019 22:30:25

368 Views

Let’s say the following is our character array:Character arr[] = { 'V', 'e', 'h', 'i', 'c', 'l' , 'e' };To convert the above character array to IntStreamIntStream stream = Stream.of(arr).flatMapToInt(IntStream::of);We have used the flatMapToInt() method for this.The following is an example to convert character array to IntStream in Java:Example Live Demoimport ... Read More

Advertisements