Samual Sam has Published 2310 Articles

What is long long in C/C++?

Samual Sam

Samual Sam

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

8K+ Views

In some cases we use long long in C or C++. Here we will see what is basically long long is? The long long takes twice as much memory as long. In different systems, the allocated memory space differs. On Linux environment the long takes 64-bit (8-bytes) of space, and ... Read More

Variable length arguments for Macros in C

Samual Sam

Samual Sam

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

1K+ Views

We know that we can use variable length arguments for functions in C. For that we have to use ellipsis (…). Similarly for macros, we can use variable length arguments. Here also we have to include ellipsis, The ‘__VA_ARGS__’ is used to handle variable length arguments. Concatenation operator ‘##’ is ... Read More

How to create JLabel to hold multiline of text using HTML in Java?

Samual Sam

Samual Sam

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

1K+ Views

To hold multiline of text, set HTML under JLabel −JLabel = new JLabel("" + "Line1Line2", JLabel.LEFT);The above will create multiline text in the JLabel −Line1 Line2The following is an example to create JLabel to hold multiline of text −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo {    public static void ... Read More

How to add line border to JLabel in Java?

Samual Sam

Samual Sam

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

681 Views

Use the createLineBorder() method to ad line border to JLabel −Border border = BorderFactory.createLineBorder(Color.ORANGE); label.setBorder(border);Above, we have set the line border to color orange.The following is an example to add line border to JLabel −Examplepackage my; import java.awt.Color; import java.awt.Font; import javax.swing.*; import javax.swing.border.Border; public class SwingDemo {    public ... Read More

How to filter String list by starting value in Java?

Samual Sam

Samual Sam

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

2K+ Views

Let’s first create a String list −List list = new ArrayList(); list.add("wxy"); list.add("zabc"); list.add("ddd2"); list.add("def"); list.add("ghi"); list.add("wer"); list.add("uij"); list.add("wqy");To filter String list by starting value, use filter() and startsWith() −list.stream().filter((b) -> b.startsWith("w"))The following is an example to filter string list by starting value −Exampleimport java.util.ArrayList; import java.util.List; public class Demo ... Read More

Difference between char s[] and char *s in C

Samual Sam

Samual Sam

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

2K+ Views

We have seen sometimes the strings are made using char s[], or sometimes char *s. So here we will see is there any difference or they are same?There are some differences. The s[] is an array, but *s is a pointer. For an example, if two declarations are like char ... Read More

How can I filter string value with starting letter?

Samual Sam

Samual Sam

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

3K+ Views

Let’s say the following is our String List −List list = Arrays.asList("Jonny", "David", "Tony", "Jacob", "Smith", "Bravo", "Gayle", "John");Now filter the string value with starting letter −Stream stream = list.stream().filter(name -> name.startsWith("J"));The following is an example to filter string value with starting letter −Exampleimport java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import ... Read More

Implicit return type int in C

Samual Sam

Samual Sam

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

480 Views

If some function has no return type, then the return type will be int implicitly. If return type is not present, then it will not generate any error. However, C99 version does not allow return type to be omitted even if it is int.Example#include my_function(int x) {    return x ... Read More

How to Map double to int Object with mapToInt and mapToObj in Java?

Samual Sam

Samual Sam

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

477 Views

At first, we have set the stream −Stream.of(3.5, 4.7, 7.9, 8.2, 9.1, 10.5, 12.3, 15.8)Now to Map double to int Object, use mapToObj −.mapToInt(Double::intValue) .mapToObj(a -> "val" + a)The following is an example to Map double to int Object with mapToInt and mapToObj −Exampleimport java.util.stream.Stream; public class Demo {   ... Read More

Map to add String value to each element in Java

Samual Sam

Samual Sam

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

838 Views

Let’s say the following is our String List −List list = Arrays.asList("Football", "Basketball", "Hockey", "Cricket", "Fencing");Now, map to add string to each element −List str = list.stream().map(name -> "Sports " + name + " Outdoor")    .collect(Collectors.toList());Above, we have added “Sports” and “Outdoor” strings to each element.The following is an ... Read More

Advertisements