Questions tagged [field]

In computer science a field is a smaller piece of data from a larger collection.

In computer science, data that has several parts can be divided into fields. Relational databases arrange data as sets of database records, also called rows or tuples. Each record consists of several fields, also called attributes; the fields of all records form the columns.

In object-oriented programming, field (also called data member or member variable) is the data encapsulated within a class or object. In the case of a regular field (also called instance variable), for each instance of the object there is an instance variable: for example, an Employee class has a Name field and there is one distinct name per employee. A static field (also called class variable) is one variable, which is shared by all instances.

Source: Field (Computer Science) - Wikipedia article

Related tags:

5904 questions
1636
votes
15 answers

Why does Java have transient fields?

Why does Java have transient fields?
Animesh
  • 16,648
  • 3
  • 18
  • 8
1505
votes
33 answers

What is the difference between a field and a property?

In C#, what makes a field different from a property, and when should a field be used instead of a property?
Anonymous
557
votes
14 answers

How to read the value of a private field from a different class in Java?

I have a poorly designed class in a 3rd-party JAR and I need to access one of its private fields. For example, why should I need to choose private field is it necessary? class IWasDesignedPoorly { private Hashtable…
Frank Krueger
  • 69,552
  • 46
  • 163
  • 208
523
votes
30 answers

In a Django form, how do I make a field readonly (or disabled) so that it cannot be edited?

In a Django form, how do I make a field read-only (or disabled)? When the form is being used to create a new entry, all fields should be enabled - but when the record is in update mode some fields need to be read-only. For example, when creating a…
X10
  • 17,155
  • 7
  • 30
  • 28
462
votes
7 answers

Add new field to every document in a MongoDB collection

How can I add a new field to every document in an existent collection? I know how to update an existing document's field but not how to add a new field to every document in a collection. How can I do this in the mongo shell?
itsme
  • 48,972
  • 96
  • 224
  • 345
406
votes
14 answers

Public Fields versus Automatic Properties

We're often told we should protect encapsulation by making getter and setter methods (properties in C#) for class fields, instead of exposing the fields to the outside world. But there are many times when a field is just there to hold a value and…
I. J. Kennedy
  • 24,725
  • 16
  • 62
  • 87
314
votes
9 answers

jQuery - Detect value change on hidden input field

I have a hidden text field whose value gets updated via an AJAX response. When this value changes, I would like to fire an AJAX request. Can anyone advise on how to detect the change? I have…
Ben
  • 6,026
  • 11
  • 51
  • 72
250
votes
8 answers

How to empty input field with jQuery

I am in a mobile app and I use an input field in order user submit a number. When I go back and return to the page that input field present the latest number input displayed at the input field. Is there any way to clear the field every time the page…
kosbou
  • 3,919
  • 8
  • 31
  • 36
238
votes
17 answers

How to update only one field using Entity Framework?

Here's the table Users UserId UserName Password EmailAddress and the code.. public void ChangePassword(int userId, string password){ //code to update the password.. }
h3n
  • 5,142
  • 9
  • 46
  • 76
190
votes
9 answers

Javascript - removing undefined fields from an object

Is there a clean way to remove undefined fields from an object? i.e. > var obj = { a: 1, b: undefined, c: 3 } > removeUndefined(obj) { a: 1, c: 3 } I came across two solutions: _.each(query, function removeUndefined(value, key) { if…
Damian
  • 2,223
  • 3
  • 16
  • 12
189
votes
4 answers

Retrieve only static fields declared in Java class

I have the following class: public class Test { public static int a = 0; public int b = 1; } Is it possible to use reflection to get a list of the static fields only? I'm aware I can get an array of all the fields with…
Anders
  • 1,977
  • 2
  • 11
  • 10
178
votes
12 answers

disable all form elements inside div

is there a way to disable all fields (textarea/textfield/option/input/checkbox/submit etc) in a form by telling only the parent div name in jquery/javascript?
amirash
  • 2,419
  • 5
  • 24
  • 26
174
votes
10 answers

Overriding fields or properties in subclasses

I have an abstract base class and I want to declare a field or a property that will have a different value in each class that inherits from this parent class. I want to define it in the baseclass so I can reference it in a base class method - for…
flytzen
  • 7,348
  • 5
  • 38
  • 54
170
votes
7 answers

Java Lombok: Omitting one field in @AllArgsConstructor?

If I specify @AllArgsConstructor using Lombok, it will generate a constructor for setting all the declared (not final, not static) fields. Is it possible to omit some field and this leave generated constructor for all other fields?
user3656823
  • 1,703
  • 2
  • 10
  • 4
159
votes
10 answers

How to remove leading and trailing whitespace in a MySQL field?

I have a table with two fields (countries and ISO codes): Table1 field1 - e.g. 'Afghanistan' (without quotes) field2 - e.g. 'AF'(without quotes) In some rows the second field has whitespace at the start and/or end, which is affecting…
KB.
  • 3,549
  • 4
  • 23
  • 29
1
2 3
99 100