Use Reference Parameters in C++

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

259 Views

Here we will see how to pass reference of some variable in C++. Sometimes we call it as “Call by Reference”.The call by reference method of passing arguments to a function copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access the actual argument used in the call. This means that changes made to the parameter affect the passed argument.To pass the value by reference, argument reference is passed to the functions just like any other value. So accordingly you need to declare the function parameters as reference types as in ... Read More

Java DatabaseMetaData supportsResultSetType Method with Example

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

183 Views

While creating a Statement object you can choose the concurrency and the type of the ResultSet object using the following variant of the createStatement() method −Statement createStatement(int resultSetType, int resultSetConcurrency)ResultSet ConcurrencyThe concurrency of the ResultSet object determines whether its contents can be updated or not.The ResultSet interface provides two values to specify the concurrency namely −CONCUR_READ_ONLY: If you set this as a value of the concurrency while creating the ResultSet object you cannot update the contents of the ResultSet you can only read/retrieve them.CONCUR_UPDATABLE: If you set this as a value of the concurrency while creating the ResultSet object you ... Read More

Logical NOT Operator in JavaScript: Detailed Explanation with Examples

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

169 Views

NOT operatorThe logical NOT operator gives true for false values and false for true values. Live DemoExample var x = 200; var y = 300; document.getElementById("logical").innerHTML = !(x < y) + "" + !(x > y); Outputfalse true

Designated Initializers in C

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

993 Views

In C90 standard we have to initialize the arrays in the fixed order, like initialize index at position 0, 1, 2 and so on. From C99 standard, they have introduced designated initializing feature in C. Here we can initialize elements in random order. Initialization can be done using the array index or structure members. This extension is not implemented in GNU C++.If we specify some index and put some value, then it will be look like this -int arr[6] = {[3] = 20, [5] = 40}; or int arr[6] = {[3]20, [5]40};This is equivalent to this:int arr[6] = {0, 0, ... Read More

Set Color to MatteBorder in Java

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

198 Views

Set color to MatteBorder using the Color class −Border border = new MatteBorder(5, 10, 5, 5, Color.BLUE);Now, set it to a button component in Java −JButton button = new JButton("Matte Border"); button.setBorder(border);The following is an example to set color to MatteBorder in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.border.Border; import javax.swing.border.EtchedBorder; import javax.swing.border.MatteBorder; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Demo");       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED);       Border border = new MatteBorder(5, ... Read More

Get Day Name from Timestamp in MySQL

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

321 Views

To get the day name from timestamp, use dayname() function −select dayname(yourColumnName) from yourTableName;    Let us first create a table :    mysql> create table DemoTable    (    LoginDate timestamp    ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-06-01'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2019-06-02'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-06-03'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-06-04'); Query OK, 1 row affected (0.11 sec) mysql> insert into ... Read More

Check If a File Exists Using Standard C/C++

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

18K+ Views

The only way to check if a file exist is to try to open the file for reading or writing.Here is an example −In CExample#include int main() {    /* try to open file to read */    FILE *file;    if (file = fopen("a.txt", "r")) {       fclose(file);       printf("file exists");    } else {       printf("file doesn't exist");    } }Outputfile existsIn C++Example#include #include using namespace std; int main() {    /* try to open file to read */    ifstream ifile;    ifile.open("b.txt");    if(ifile) {       cout

Change Color of Button in iOS When Clicked

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

2K+ Views

Imagine you’re playing a song and as soon as you press the stop button, the color of the button should turn to red. This is one of the many scenario where you might need to change the color of button when it is clicked.In this tutorial we will see how to change the background color of a button when it is clicked. So let’s get started!Step 1 − Open Xcode → New Projecr → Single View Application → Let’s name it “ChangeButtonColor”Step 2 − In the Main.storyboard create one button and name it stop.Step 3 − Create @IBAction of the ... Read More

Get Application Name and Version Information of a Browser in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

2K+ Views

Javascript has provided a navigator object with which we can find any information regarding the browser. To get the application name and version information, navigator object has provided navigator.appName() and navigator.appVersion() respectively. Let's discuss each of them individually.Application Name of the browserTo get the application name, the navigator object has provided navigator.appName(). It may sound weird that "Netscape" is the application name for IE11, Chrome, Firefox, and Safari. So the output we get when we use navigator.appName() is Netscape.ExampleLive Demo document.write(navigator.appName); OutputNetscapeBrowser version informationTo get the browser version information, the navigator object has provided ... Read More

Hide and Display JComboBox with JCheckBox in Java

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

631 Views

To toggle visibility with JCheckBox, use isVisible() method:JCheckBox toggleVisibility = new JCheckBox("Hide/Show"); toggleVisibility.setSelected(comboBox.isVisible()); toggleVisibility.addItemListener(e -> {    comboBox.setVisible(e.getStateChange() == ItemEvent.SELECTED); });The following is an example to hide and display JCombobox with a JCheckBox in Java:Exampleimport java.awt.BorderLayout; import java.awt.event.ItemEvent; import javax.swing.*; public class SwingDemo {    JFrame frame;    SwingDemo(){       frame = new JFrame("ComboBox");       String Sports[]={"Select", "Tennis", "Cricket", "Football"};       JComboBox comboBox = new JComboBox(Sports);       comboBox.setBounds(50, 50, 90, 20);       frame.add(comboBox, BorderLayout.CENTER);       JCheckBox toggleVisibility = new JCheckBox("Hide/Show");       toggleVisibility.setSelected(comboBox.isVisible());       toggleVisibility.addItemListener(e ... Read More

Advertisements