Samual Sam has Published 2492 Articles

How to add line border to JLabel in Java?

Samual Sam

Samual Sam

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

443 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

1K+ 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

2K+ 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

378 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

363 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

641 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

Parameter Passing Techniques in C/C++

Samual Sam

Samual Sam

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

6K+ Views

In C we can pass parameters in two different ways. These are call by value, and call by address, In C++, we can get another technique. This is called Call by reference. Let us see the effect of these, and how they work.First we will see call by value. In ... Read More

How to disable a JLabel in Java?

Samual Sam

Samual Sam

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

374 Views

To disable a JLabel, use the setEnabled() method −JLabel label; label.setEnabled(false);The following is an example to disable a JLabel −package my; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import javax.swing.*; import javax.swing.border.Border; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Demo"); ... Read More

How will you show memory representation of C variables?

Samual Sam

Samual Sam

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

454 Views

Here we will see how to print the memory representation of C variables. Here we will show integers, floats, and pointers.To solve this problem, we have to follow these steps −Get the address and the size of the variableTypecast the address to the character pointer to get byte addressNow loop ... Read More

Advertisements